我JSON这样如何在表格视图中显示嵌套的JSON数据?
{ "StartElement": {
"Count": "14",
"Notification": [
{
"contact": null,
"Date": "20 June 2016",
"Message": null,
"Viewed": "1"
},
{
"contact": "99230332210",
"Date": "20 June 2016",
"Message": "I need help",
"Viewed": "1"
}
}
和我的JSON在viewDidLoad
分析是这样的:
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://www.someURL.com/JSONToFetch?"]];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSString *requestReply = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"requestReply: %@", requestReply);
NSLog(@"code: %d",[(NSHTTPURLResponse*)response statusCode]);
}] resume];
现在,我想告诉"Message"
内容转换成表格视图单元。如何将此数据存储到数组中,以便我可以将它加载到cellForRowAtIndexPath
方法中。感谢名单为帮助:)
https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSJSONSerialization_Class/你的反应首先阅读。 – Joshua