如何在 XCode4.2 的调试器中监视变量

发布于 2024-12-27 05:12:59 字数 1202 浏览 3 评论 0原文

我的核心数据实体有一些 int16 属性,我想在调试过程中监视它们

,但遇到了一些麻烦。

首先,我想监视名为“order”和“total”的属性,它们的类型都是整数16

这是我的调试代码。

NSArray *expenseTypes = [self.managedObjectContext executeFetchRequest:request error:&error];
NSLog(@"expenseTypes: %d",[expenseTypes count]);
i = 1;
for (ExpenseType *one in expenseTypes)
    NSLog(@"..%d : %@ : %d",i++,[one name],[[one order] intValue]);

打印出来的值应该是一些非常常见的小非负整数,如 0,1,2,3 等。

但在调试器中,结果是这样的:

在此处输入图像描述

忘记这个奇怪的名字(那些介于两个之间的名字)冒号),但整数结果非常荒谬,

有些数字只是我想要的,但其他数字似乎是随机的,

这是我设置这些integer16属性的代码:

NSUInteger all;
all = (NSUInteger)[self.superTypeEntity total];
[newManagedObject setValue:[NSNumber numberWithUnsignedInt:all]
                        forKey:@"order"];

我认为问题不在于这些代码。

整数16个属性是NSNumber的实例,所以我使用("%d",[xx intValue])

有什么问题吗?

我总是很难监视XCode中的一些变量,尤其是一些核心数据,每次我都必须在下面的地方搜索它们,并且所有变量都以指针的格式显示,我很难检查是否是字符串,或者整数是我想要的或不想要的。

在此处输入图像描述

抱歉我提出了一些愚蠢的问题,因为我是 IOS 开发的新手,

但我希望有人能来来帮助我!

非常感谢!

I have a few int16 attributes of my core data entities, and I want to surveil them during the debugging

but I met some troubles.

First, I want to surveil attributes named "order" and "total", both of the type integer 16.

and here is my code for debugging.

NSArray *expenseTypes = [self.managedObjectContext executeFetchRequest:request error:&error];
NSLog(@"expenseTypes: %d",[expenseTypes count]);
i = 1;
for (ExpenseType *one in expenseTypes)
    NSLog(@"..%d : %@ : %d",i++,[one name],[[one order] intValue]);

and the values printed out are supposed to be some very common and small non-negative integers like 0,1,2,3,etc.

but in the debugger it turn out to be like this:

enter image description here

forget about this strange names(those who between two colons), but the integers turn out to be very ridiculous ,

some of the numbers are just want I want, but others seems random,

and here is my code to set these integer16 attributes:

NSUInteger all;
all = (NSUInteger)[self.superTypeEntity total];
[newManagedObject setValue:[NSNumber numberWithUnsignedInt:all]
                        forKey:@"order"];

I think the problems is not about these code.

integer 16 attributes are NSNumber's instaces, so I use ("%d",[xx intValue])

is there something wrong with it?

I always have a difficult time surveilling some variables in XCode, especially some of core data, everytime I have to search for them in the place below and all the variables are displayed in formats of pointers, I can hardly check out whether a string, or a integer is what I want or not.

enter image description here

Sorry for my silly questions, since I am a green hand of IOS development,

But I am hoping someone come to help me!

Thanks more than a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别念他 2025-01-03 05:12:59

嘿,我自己找到了答案,在设置值的代码中我错过了一个重要的方法,

它应该是这样的:

all = (NSUInteger)[[self.superTypeEntity total] **intValue**];

这样打印出来的值就可以了。

Hey I found the anwser by myself, in the code that set the value I miss an important method,

and it should be like this:

all = (NSUInteger)[[self.superTypeEntity total] **intValue**];

in this way the values printed out would be ok.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文