开发者

Odd NSNumber Output - Core Data

开发者 https://www.devze.com 2023-04-11 21:38 出处:网络
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 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

精彩评论

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

关注公众号