-3
现在我知道这意味着它试图获取NSString中的所有密钥,这是不可能的。但是,我不知道为什么我的字典是NSString。iOS: - [__ NSCFString allKeys]:无法识别的选择器发送到实例0x7976c750
return [requestManager POST:@"/api/showData"
parameters:params
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"the response object%@",responseObject);
NSMutableArray *responseObjects = [[NSMutableArray alloc] init];
for (NSDictionary *node in responseObject) {
Model *data = [[Model alloc] initWithDictionary:node];
[responseObjects addObject:data];
}
handler(YES,responseObjects);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
handler(NO,nil);
}];
该代码发送到服务器的请求,并得到以下成功响应
响应对象{ “ERROR_CODE”= 1; message =“找不到”; status = error; }
在我initWithDictionary方法我的模型类,这是我有
//Model Class
- (id)initWithDictionary:(NSDictionary *)dict{
self = [super init];
if (self) {
NSLog(@"the dict is %@",dict);
if ([[dict allKeys] containsObject:@"error_code"]) {
}
return self;
}
上面一行是什么原因造成我的问题。我登录字典在此方法中,这是我所得到的
“的字典是状态”
你没有显示'dict'的创建位置和设置值。编辑问题并将其添加到它。 – zaph 2015-04-05 17:00:37
我编辑它,但它是通过模型类initwithdictionary创建的。 – 2015-04-05 17:05:35
应用程序崩溃是因为您没有传递字典而是字符串,请检查您从后端获取的数据的JSON模式。 – HepaKKes 2015-04-05 17:10:43