我已经编写了以下代码,但我不断得到零。我已经尝试了许多不同的变体,但我失败得异常艰难。
这是我从服务器得到的。两个对象。
[{"description":"yolo.","name":"ye","id":1},{"description":"sMITH","name":"John","id":2}]
任何帮助将不胜感激......谢谢。
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError];
SBJsonParser *jsonParser = [[SBJsonParser alloc] init];
NSArray *jsonObjects = [jsonParser objectWithData:response];
NSMutableString *yolo = [[NSMutableString alloc] init];
for ( int i = 0; i < [jsonObjects count]; i++ ) {
NSDictionary *jsonDict = [jsonObjects objectAtIndex:i];
NSString *IDID = [jsonDict objectForKey:@"id"];
NSString *name = [jsonDict objectForKey:@"name"];
NSLog(@"ID: %@", IDID); // THIS DISPLAYS
[yolo appendString: IDID]; // THIS seems to be causing the new error...
[yolo appendString:@": "];
[yolo appendString: name];
NSLog(@"%@", yolo); // RETURNS NIL
}
编辑:
目前我的新错误是......
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[NSDecimalNumber 长度]:无法识别的选择器发送到实例 0x81b89f0”