这里我正在创建一个应用程序,我正在使用Pickerview。我通过这种编码成功创建了选择器视图:
(void)viewDidLoad {
[super viewDidLoad];
pickerview =[[UIPickerView alloc]init];
pickerview.frame =CGRectMake(180,250, 145, 10);
pickerview.showsSelectionIndicator=YES;
[self.view addSubview:pickerview];
pickerview.delegate=self;
pickerview.dataSource=self;
iTeacherAppDelegate* delegate = (iTeacherAppDelegate*)[[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [delegate managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Subject" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
***NSArray *temp = [[context executeFetchRequest:fetchRequest error:nil]retain];***
[fetchRequest release];
}
在上面的编码中,我发现了来自executefetchrequest的临时数组。我无法在选择器视图中使用此数组进行显示。当我们尝试然后显示变量数据不是cfstring
答案 0 :(得分:0)
您的NSArray * temp在viewDidLoad之外无效。将它设为您的类的属性,它们将可用于选择器数据源方法。