#define kBgQueue dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define kLatestKivaLoansURL [NSURL URLWithString:@"http://api.kivaws.org/v1/loans/search.json?status=fundraising"]
dispatch_async(kBgQueue, ^{
NSData* data = [NSDatadataWithContentsOfURL:
kLatestKivaLoansURL];
[selfperformSelectorOnMainThread:@selector(fetchedData:)
withObject:data waitUntilDone:YES]; });
- (void)fetchedData:(NSData *)responseData {
//parse out the json data
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData //1
options:kNilOptions error:&error];
NSArray* latestLoans = [json objectForKey:@"loans"]; //2
NSLog(@"loans: %@", latestLoans); //3
}