如何在 XCode4.2 的调试器中监视变量
我的核心数据实体有一些 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:
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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿,我自己找到了答案,在设置值的代码中我错过了一个重要的方法,
它应该是这样的:
这样打印出来的值就可以了。
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:
in this way the values printed out would be ok.