[英]getting error as -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance
[英]App crashes with error [__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance
我从服务器得到 json 响应作为 json 数组。
[{
"id": 514524,
"firstName": "aa",
"lastName": "vv",
"fullName": "aa vv"
}, {
"id": 51411524,
"firstName": "qq",
"lastName": "vv",
"fullName": "qq vv"
}]
但是,如果我在didSelectRowAtIndexpath
使用indexPath.row
访问该数组的元素,如下所示,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ProfileViewController *obj = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
obj.isFromScreen = @"Authorized People";
obj.profileArray = [authorizedPeopleArray objectAtIndex:indexPath.row];
[self.navigationController pushViewController:obj animated:YES];
}
我收到一个错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x7aa78d20'
得到你的response
如下
NSArray *yourArry = [NSJSONSerialization JSONObjectWithData:JSONData
options:kNilOptions error:& error];
在didselectrowatindexpath
获取例如firstName
任何值,如下所示
NSString *firstName=[NSString stringWithFormat:@"%@",
[[yourArry objectAtIndex:indexPath.row]valueForKey:@"firstName"]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.