开发者

fetchrequest array from core data use in picker view

here I am creating an app and I am using Pickerview. I successfully created picker view by this coding:

(void)viewDidLoad {

    [super viewDidLoad];
    pickerview =[[UIPickerView alloc]init];

    pickerview.frame =CGRectMake(180,250, 145, 10);
    pickerview.showsSelectionIndicator=YES;开发者_Python百科

    [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];

    }

In the above coding I am finding the temp array which are coming from executefetchrequest. and I could not use this array in picker view for showing. and when we try then show variable data is not a cfstring


Your NSArray *temp is not valid outside of viewDidLoad. Make this a property of your class and it will them be available to use in the picker data source methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜