我对我的iPhone应用程序使用超文本传输协议请求。当我想写字典的时候,有一个NSException...
[__NSCFDictionary objectAtIndex:]: unrecognized selector下面是connectionDidFinishLoading的代码:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"responseString");
NSLog(responseString);
[responseData release];
NSArray *tableau = [responseString JSONValue];
NSLog(@"the newt line give me the exception");
NSDictionary *dico = [tableau objectAtIndex:0];responseString告诉我:
{"token":"8569fe2e095d83a4692812fa808f84da"}我以前用过那段代码,但它不想运行这些数据...
如果你能帮我,那就太好了!谢谢!
发布于 2011-06-27 20:15:47
JSON中的数组由[]分隔,而对象/字典则由{}分隔。因为你的回答是
{"token":"8569fe2e095d83a4692812fa808f84da"}它不是一个数组,而是一个单独的对象/字典。
尝试:
NSDictionary *dico = [responseString JSONValue];https://stackoverflow.com/questions/6492676
复制相似问题