我正在從JSON Web服務JSON陣列選擇器視圖iPhone
List ARRAY: (
{
assets = (
{
identity = 34DL3611;
systemId = 544507;
},
{
identity = 34GF0512;
systemId = 5290211;
},
{
identity = 34HH1734;
systemId = 111463609;
},
{
identity = 34HH1736;
systemId = 111463622;
},
{
identity = 34YCJ15;
systemId = 294151155;
}
);
identity = DEMO;
systemId = 4921244;
})
該數據通過使用此代碼:
NSArray *list =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"Response data: %@", responseString);
NSLog(@"List ARRAY: %@", list);
NSDictionary *dict = [list objectAtIndex: 0];
NSMutableArray *vehicleGroups = [dict objectForKey:@"identity"];
NSLog(@"Vehicle Groups: %@", vehicleGroups);
這裏是我使用的選擇器代碼:
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent :(NSInteger)component {
return [vehicleGroups count];}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{return nil;}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
}
應用程序崩潰在線
return [vehicleGroups count];
委託方法numberOfRowsInComponent
的pickerView
。我不明白 - 爲什麼我面臨這個問題?
//代碼////
NSArray *list =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"Response data: %@", responseString);
NSLog(@"List ARRAY: %@", list);
NSDictionary *dict = [list objectAtIndex: 0];
vehicleList = [dict objectForKey: @"assets"];
self.vehicleGroups = [[NSMutableArray alloc] init];
vehicleGroups = [dict objectForKey:@"identity"];
NSLog(@"Vehicle Groups: %@", vehicleGroups);
NSString *identity = [dict objectForKey: @"identity"];
NSString *systemid = [dict objectForKey:@"systemId"];
self.listVehicles = [[NSMutableArray alloc] init];
self.listVehiclesID =[[NSMutableArray alloc]init];
NSLog(@"GroupOfVehicles: %@", groupOfVehicles);
for (NSUInteger index = 0; index < [vehicleList count]; index++) {
itemDict = [vehicleList objectAtIndex: index];
[self.listVehicles addObject:[itemDict objectForKey:@"identity"]];
[self.listVehiclesID addObject:[itemDict objectForKey:@"systemId"]];
}
NSLog(@"Group Name: %@", identity);
NSLog(@"Assets: %@", listVehicles);
NSLog(@"Assets System ID: %@", listVehiclesID);
NSLog(@"GroupSystemID: %@", systemid);
有沒有什麼記錄,它給了我一個消息:程序接收到的信號:EXC_BAD_ACCESS – 2012-01-17 07:07:39
有什麼可以解決的問題? – 2012-01-17 07:11:04
我收到了:Vehicle Groups:DEMO – 2012-01-17 07:13:29