请帮我调试这段代码
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
NSError *error = nil;
NSURL *urls = [NSURL URLWithString:[NSString stringWithFormat:@"http://cnapi.iconnectgroup.com/api/UserProfile?id=1"]];
NSString *json = [NSString stringWithContentsOfURL:urls encoding:NSASCIIStringEncoding error:&error];
NSLog(@"JSon data = %@ and Error = %@", json, error);
if(!error)
{
NSData *jsonData = [json dataUsingEncoding:NSASCIIStringEncoding];
NSArray *myJsonArray = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
NSLog(@"JSON data is :: %@", myJsonArray);
for(NSDictionary *jsonDictionary in myJsonArray)
{
//NSString *uids = jsonDictionary[@"UID"];
NSString *address1 = jsonDictionary[@"Address1"];
NSString *address2 = jsonDictionary[@"Address2"];
NSString *city = jsonDictionary[@"City"];
NSString *emailId = jsonDictionary[@"EmailID"];
NSString *fname = jsonDictionary[@"FName"];
NSString *fax = jsonDictionary[@"Fax"];
NSString *lname = jsonDictionary[@"LName"];
NSString *password = jsonDictionary[@"Password"];
NSString *phone = jsonDictionary[@"Phone"];
NSString *state = jsonDictionary[@"State"];
NSString *uids = [jsonDictionary objectForKey:@"UID"];
NSString *zip = jsonDictionary[@"Zip"];
NSString *company = jsonDictionary[@"company"];
NSString *department = jsonDictionary[@"department"];
NSLog(@"Uid is = %@", uids);
NSLog(@"First Name = %@", fname );
NSLog(@"Last Name = %@", lname);
NSLog(@"Company = %@", company);
NSLog(@"Email Id = %@", emailId);
NSLog(@"Password = %@", password);
NSLog(@"Department = %@", department);
NSLog(@"Address 1 = %@", address1);
NSLog(@"Address 2 = %@", address2);
NSLog(@"City = %@", city);
NSLog(@"State = %@", state);
NSLog(@"Zip = %@", zip);
NSLog(@"Phone = %@", phone);
NSLog(@"Fax = %@", fax);
}
}
});
[activity stopAnimating];
self.activity.hidden = YES;
}
图片会告诉你错误在哪里。单击 stepover 进行调试后出现此错误。我也试过
NSString *address1 = [jsonDictionary objectForKey:@"Address1"];