我想制作一个与 API 通信的应用程序,但我无法找出我的解析有什么问题。
这是代码:
NSJSONSerialization *jsonObject = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSLog(@" jsonObject: %@", jsonObject);
NSURL *img1 = [[NSURL alloc] initWithString:[jsonObject obj]];
NSURL *img2 = [[NSURL alloc] initWithString:[jsonObject valueForKey:@"img2"]];
NSURL *img3 = [[NSURL alloc] initWithString:[jsonObject valueForKey:@"img3"]];
NSData *data1 = [[NSData alloc] initWithContentsOfURL:img1];
NSData *data2 = [[NSData alloc] initWithContentsOfURL:img2];
NSData *data3 = [[NSData alloc] initWithContentsOfURL:img3];
UIImage *image1 = [[UIImage alloc] initWithData:data1];
UIImage *image2 = [[UIImage alloc] initWithData:data2];
UIImage *image3 = [[UIImage alloc] initWithData:data3];
这是树:
jsonObject: (
{
img1 = "http://www.kozpontiszalon.hu/images/ads/kupon_aug_3.png";
img2 = "anotherlink";
img3 = "anotherlink";
}
)
感谢你们对我的帮助!