我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