0
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.krsconnect.no/community/api.html?method=bareListEventsByCategory&appid=620&category-selected=350&counties-selected=Vest-Agder,Aust-Agder"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSDictionary *object = [parser objectWithString:json_string error:nil];
//appDelegate.books = [[NSMutableArray alloc] initWithCapacity:0];
appDelegate.books1 = [[NSMutableArray alloc] init];
NSArray *results = [parser objectWithString:json_string error:nil];
for (int i=0; i<[results count]; i++) {
Book1 *aBook = [[Book1 alloc] initWithDictionary:[results objectAtIndex:i]];
[appDelegate.books1 addObject:aBook];
Book1 *mybook=[appDelegate.books1 objectAtIndex:i];
NSString*test=mybook.location;
NSLog(test);
}
Dicionary一度のために解析JSONは
- (id)initWithDictionary:(NSDictionary*) dict {
self.date = [dict valueForKey:@"date"];
self.location = [dict valueForKey:@"location"];
self.municipality = [dict valueForKey:@"municipality"];
self.title = [dict valueForKey:@"title"];
return self;
}
これはプログラミングの問題であるため、Stackoverflow.comでこれを試してみるとよいでしょう。実際の質問も良いでしょう。 – deceze
を読んで質問をフォーマットしてください – Mark