我使用NSArray
在DetailViewController中显示数据。现在我已将其更改为NSMutableArray
,当我推送到DetailViewController时它会在viewWillAppear
达到- (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;
}
时崩溃。是什么导致这种情况?
从viewController发送到DetailViewController:
@property (strong, nonatomic) NSMutableArray *detailsDataSource;
@property int detailIndex;
}
收到:
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"]];
viewWillAppear中:
-[__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'
这是日志中显示内容的一部分:
{{1}}
答案 0 :(得分:1)
NSMutableArray是NSArray的子类,这意味着NSArray中的任何方法都可以与NSMutableArray使用完全相同的方式。您能否发布崩溃日志或调试器中的跟踪。
答案 1 :(得分:1)
winesdetailViewController.detailsDataSource
是NSMutableArray
,其中包含NSArray
。我猜你以前你的数组包含了许多字符串,你真的想用它来创建它:
winesdetailViewController.detailsDataSource = [[NSMutableArray alloc] initWithArray:sortedWines];
答案 2 :(得分:0)
您可能需要使用[NSMutableArray arrayWithArray:otherArray]