-4

I am new to iOS development so this is probably a stupid question, I want to display an NSNumber in a label on a viewcontroller how do I cast it as a string so it will work? Here is the line of code:

cell.textLabel.text = videos.videoID; // videoID is an NSNumber

Sam Cromer
  • 687
  • 3
  • 12
  • 31

3 Answers3

1
NSNumberFormatter *nf = [NSNumberFormatter new];
cell.textLabel.text = [nf stringFromNumber:videos.videoID]
Eugene
  • 10,006
  • 4
  • 37
  • 55
1
cell.textLabel.text = videos.videoID.stringValue;
Gavin
  • 8,204
  • 3
  • 32
  • 42
1
cell.textLabel.text = [NSNumberFormatter localizedStringFromNumber:videos.videoID numberStyle:NSNumberFormatterNoStyle];
Léo Natan
  • 56,823
  • 9
  • 150
  • 195