Ready to use PickerViewController
NSArray *simpleDataArray = @[@"Jan", @"Feb", @"Mar", @"Apr", @"May"];
JKPickerViewController *pickerVC = [JKPickerViewController picker];
[pickerVC setDataSource:@[simpleDataArray]];
[pickerVC showPickerInViewController:self
withSelectionHandler:^(JKPickerViewController *pickerVC, id selectedData) {
if (selectedData) {
NSLog(@"Selected Data = %@", selectedData);
}
}];
NSArray *arrayOfDic = @[@{@"id": @"1", @"month": @"Jan"},
@{@"id": @"2", @"month": @"Feb"},
@{@"id": @"3", @"month": @"Mar"},
@{@"id": @"4", @"month": @"Apr"},
@{@"id": @"5", @"month": @"May"}];
JKPickerViewController *pickerVC = [JKPickerViewController picker];
[pickerVC setDataSource:@[arrayOfDic]];
[pickerVC setTitleKeyPath:@"month"];
[pickerVC showPickerInViewController:self
withSelectionHandler:^(JKPickerViewController *pickerVC, id selectedData) {
if (selectedData) {
NSLog(@"Selected Data = %@", selectedData);
}
}];
For array
[pickerVC setSelectedRowData:@[@"Apr"]];
For array of dictionary
[pickerVC setSelectedRowData:@[@{@"id": @"4", @"month": @"Apr"}]];