我无法理解为什么我的应用程序崩溃以及如何避免它,
在.h
@property (nonatomic) NSArray * PersonsFromSearch;
米
碰撞区
viewDidLoad
NSArray* nameArr;
if([defaults objectForKey:@"Person1"])
{
nameArr = [NSArray arrayWithObjects: [defaults objectForKey:@"Person1"],Nil];//ate
PersonsFromSearch = nameArr;//crashes here :(
NSLog(@"not crashed yet");
}
在同一个文件分配给本地存储
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self dismissKeyboard];
//test solution :)
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];//store it !
[defaults setObject:[PersonsFromSearch objectAtIndex:indexPath.row] forKey:@"Person1"];//store 1 person Full details
[[NSUserDefaults standardUserDefaults] synchronize];//store indeed
//keep with code
}
崩溃细节:
2013-11-10 08:50:47.938 RevealControllerProject[1375:a0b]-[__NSCFArray objectForKey:]:无法识别的选择器发送到实例 0xe008a00
2013-11-10 08:50:47.942 RevealControllerProject[1375:a0b] *由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSCFArray objectForKey:]:无法识别的选择器发送到实例 0xe008a00”
*首先抛出调用栈: