Possible Duplicate:
How to convert NSNumber to NSString
Segue to pass string from MainViewController to DetailViewController:
MainViewController.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"DetailSegue"]) {
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
DetailViewController *detailViewController = [segue destinationViewController];
//Name:
detailViewController.detailName = [[sortedObjects objectAtIndex:selectedRowIndex.row] valueForKey:@"Name"];
//Attempt with number:
detailViewController.detailPopularity = [[sortedObjects objectAtIndex:selectedRowIndex.row] valueForKey:@"Popularity"];
}
}
DetailViewController.h
//Name:
@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) NSString *detailName;
//Attempt with number:
@property (nonatomic, strong) IBOutlet UILabel *popularityLabel;
@property (nonatomic, strong) NSString *detailPopularity;
DetailViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
//Name:
nameLabel.text = detailName;
//Attempt with number:
popularityLabel.text = detailPopularity;
}
In this example the app crashes because it can't display a NSNumber in UILabel. I need to see an example on how to convert the NSNumber into a NSString so I can display it in a label, I've tried in different ways but I can't find the right combination to fix the error..