【发布时间】:2016-06-21 08:59:03
【问题描述】:
我有这样的 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"
}
}
我在 viewDidLoad 中的 JSON 解析是这样的:
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 方法中。感谢您的帮助:)
【问题讨论】:
标签: ios objective-c json