2013-04-22 67 views
0

这是我的响应代码。当我按注册按钮我的应用程序崩溃,但数据库中的数据成功插入

NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; 

NSDictionary *LoginResult = (NSDictionary*)[responseString JSONValue]; 

NSLog(@"Success"); 

NSMutableArray *wholeJsonArray = [LoginResult objectForKey:@"Response"]; 

for(NSDictionary *countname in wholeJsonArray) 
{ 

    NSString *countryName = [countname objectForKey:@"country_name"]; 
    if(countryName) 
     [countryArray addObject:countryName]; 
    NSString *stateName=[countname objectForKey:@"state_name"]; 
    if(stateName) 
     [stateArray addObject:stateName]; 
} 

上面的代码是检索到国家名称和州名。

当我调试我的代码后按按钮的应用程序应坠毁在NSString *countryName = [countname objectForKey:@"country_name"];线光标点。

+0

有没有崩溃记录? – 2013-04-22 07:01:11

+0

按钮代码发送请求 – 2013-04-22 07:03:06

+0

崩溃日志[__NSCFString objectForKey:]:无法识别的选择器发送到实例0x6a6e570 – 2013-04-22 07:04:52

回答

0

NSMutableArray *wholeJsonArray不包含NSMutableDictionary;它包含NSString。请检查您的阵列内容。

+0

它没有任何问题,因为我的应用程序工作正常之前按下注册按钮 – 2013-04-22 07:08:40

+1

@MalayPatel:没有问题。是否检查过您保存的数据是否正确? – 2013-04-22 07:13:11

相关问题