I was using an NSArray for display of data in my DetailViewController. Now I have changed it to a NSMutableArray, and it crashes when it reach viewWillAppear when I push to the DetailViewController. What can cause this?
Sent from viewController to DetailViewController:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"DetailSegue"]) {
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
WinesDetailViewController *winesdetailViewController = [segue destinationViewController];
winesdetailViewController.detailsDataSource = [[NSMutableArray alloc] initWithObjects:sortedWines,nil];
winesdetailViewController.detailIndex = selectedRowIndex.row;
}
}
Recieved:
@property (strong, nonatomic) NSMutableArray *detailsDataSource;
@property int detailIndex;
viewWillAppear:
if ([[[detailsDataSource objectAtIndex: detailIndex] valueForKey:@"Rate"] isEqual:[NSNumber numberWithInt:1]]) {
ratingImageView.image = [UIImage imageNamed:@"ratingButtonOne@2x.png"];
}
flagImageView.image = [UIImage imageNamed:[[detailsDataSource objectAtIndex: detailIndex] valueForKey:@"Flag"]];
This is part of what is displayed in log:
-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x6d2ee20
2012-08-15 00:00:16.860 Rødvinsguiden test[4240:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI isEqualToString:]: unrecognized selector sent to instance 0x6d2ee20'
winesdetailViewController.detailsDataSourceis aNSMutableArraycontaining aNSArray. I’m guessing previously your array contained a number of strings and that you actually want to create it using: