WebサービスからUIピッカービューにデータをロードしようとしています。これは空白として表示されます。以下は私のコードです。データがUIpickerviewに読み込まれない
NSMutableArray * flooring;
NSDictionary *dictionary;
NSString *floorname;
NSString *floorid;
- (void)viewDidLoad {
floorname = @"Name";
floorid = @"IntFloorId";
NSString *strURL=[NSString stringWithFormat:@"http://123.63.83.11:8002/api/Floor/LoadFloorType"];
NSData *jsonSource = [NSData dataWithContentsOfURL:
[NSURL URLWithString:strURL]];
id jsonObjects = [NSJSONSerialization JSONObjectWithData:
jsonSource options:NSJSONReadingMutableContainers error:nil];
for (NSDictionary *dataDict in jsonObjects) {
NSString *Name = [dataDict objectForKey:@"Name"];
NSString *floorid1 = [dataDict objectForKey:@"IntFloorId"];
dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
Name,floorname,floorid1,floorid, nil];
[flooring addObject:dictionary];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return flooring.count;
}
- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSDictionary *tmpDict = [flooring objectAtIndex:row];
NSString * f = [tmpDict objectForKey:@"Name"];return f;
}
助けてください。
含まれるクラスは、UIPickerViewDelegateとUIPickerViewDataSourceの両方に準拠していますか? –