-(void)viewDidLoad
{
NSString *path = [[NSBundle mainBundle] pathForREsource:@"data" ofType:@"plist"];

NSDictionary *dic = [[NSDIctionary alloc] initWithContentsOFFile:path];
self.subName = dic;
[dic release];

NSArray *keys = [[self.subName allKeys] sortedArrayUsingSelector:@selector(compare:)];
self.pickerData = keys;

NSString *selectedData = [self.pickerData objectAtIndex:0];
NSArray *array = [self.subName objectForKey:selectedData];
self.subData = array;

}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if(component == 0)
{
NSString *selectedData = [self.pickerData objectAtIndex:row];
NSArray *array = [self.subName objectForKey:selectedData];
self.subData = array;

[picker selectRow:0 inComponent:1 animated:YES];
[picker reloadComponent:1];
}
}

'Object-C' 카테고리의 다른 글

CoreData  (0) 2010.10.07
archiving  (0) 2010.10.07
pickerView  (0) 2010.10.07
imagePicker  (0) 2010.10.07
pageControl  (0) 2010.10.07
ScrollView  (0) 2010.10.07

+ Recent posts