开发者

NSException during a objectAtIndex

I'm using HTTP request for my iPhone App. When I want to made the dictionnary, there is a NSExc开发者_Go百科eption...

[__NSCFDictionary objectAtIndex:]: unrecognized selector

Here's the code for the 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 give me that:

{"token":"8569fe2e095d83a4692812fa808f84da"}

I used that code before but it want not run with those datas...

If you can help me, it would be very nice! Thank You !


Arrays in JSON are delimited by [], whilst objects/dictionaries are delimited by {}. Since your response is

{"token":"8569fe2e095d83a4692812fa808f84da"}

it is not an array — it’s a single object/dictionary.

Try:

NSDictionary *dico = [responseString JSONValue];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜