开发者

Odd NSNumber Output - Core Data

When Following the CoreDataBooks sample code and implementing it into my app, I have reached a very odd bug/glitch with an NSNumber(Integer 16).

When I have the code

cell.detailTextLabel.text = [NSString stringWithFormat:@"%i", child.marblesneeded];

开发者_如何学编程the detailTextLabel displays an odd string of numbers that changes every time I try to change the numbers. See Attached Image. Currently, it should display 0 but it displays 112917120.

Odd NSNumber Output - Core Data

Thanks!


NSNumber has a method to return you the number as string, which can be used as a label text, as follows:

cell.detailTextLabel.text = [child.marblesneeded stringValue];


Try this:

cell.detailTextLabel.text = [NSString stringWithFormat:@"%d", [child.marblesneeded intValue]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜