我想将(NSDictionary *jsonDictionary in myJsonArray)
我在 NSLog 中获得的值传递给[array addObject:[[SaveList alloc] initWithEmail:email withPhone:phone withDate:date withName:name]];
代码在这里
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
NSError *error = nil;
NSURL *url = [NSURL URLWithString:@" http:// Some url "];
NSString *json = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];
NSLog(@"\n\n JSON : %@, \n Error: %@", json, error);
if(!error)
{
NSData *jsonData = [json dataUsingEncoding:NSASCIIStringEncoding];
NSArray *myJsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
// NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
for(NSDictionary *jsonDictionary in myJsonArray)
{
NSLog(@"JSON Dictionary = %@", jsonDictionary);
NSString *name = jsonDictionary[@"Name"];
NSString *date = jsonDictionary[@"Date"];
NSString *email = jsonDictionary[@"Email"];
NSString *phone = jsonDictionary[@"Phone"];
NSLog(@"Name = %@", name);
NSLog(@"Date = %@", date);
NSLog(@"Email = %@", email);
NSLog(@"Phone = %@", phone);
}
}
});
//Table implementation
array = [[NSMutableArray alloc]init];
//**Get email, phone, date, name here**
[array addObject:[[SaveList alloc] initWithEmail:email withPhone:phone withDate:date withName:name]];
self.tableView.dataSource = self;
self.tableView.delegate = self;