Ahan Malhotra
Ahan Malhotra

Reputation: 185

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.enter image description here

Thanks!

Upvotes: 1

Views: 131

Answers (2)

Vibhor Goyal
Vibhor Goyal

Reputation: 2425

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];

Upvotes: 2

Oscar Gomez
Oscar Gomez

Reputation: 18488

Try this:

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

Upvotes: 2

Related Questions