Я получаю json-массив с сервера. Объект jsonOutput показывает 2 объекта правильно. Но я не могу отображать или извлекать данные. Может ли кто-нибудь помочь мне. Я попытался следующим образом:Невозможно прочитать данные после NSJSONSerialization
for (id key in jsonOutput) {
NSLog(@"key: %@, value: %@", key, [jsonOutput objectForKey:key]);
}
декларация: NSDictionary * jsonOutput;
actualmethods:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
data=[[NSMutableData alloc] init];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)theData
{
[data appendData:theData];
// if ([connection isEquals:connect1]){
// this is request urlConnectionRecsender
// }
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
jsonOutput= [NSJSONSerialization JSONObjectWithData:data options:nil error:nil];
for (id key in jsonOutput) {
NSLog(@"key: %@, value: %@", key, [jsonOutput objectForKey:key]);
}
}
Вы могли бы передать в переменной ошибки и проверить, что объект. Если ошибка не записывается в переменную, проверьте, есть ли у вас массив или словарь. – vikingosegundo