【发布时间】:2010-02-13 23:45:18
【问题描述】:
我正在尝试将一堆核心数据对象 (NSStrings) 添加到 NSMutableArray 中,以便我的 pickerView 可以将字符串用作其数据值。
目前,我可以在 Core Data 中将 textField 中的字符串一次保存到 sqlite 文件中。
我无法将这些对象从 Core Data sqlite 文件中拉回 NSMutable 数组中。
这是将对象添加到 sqlite 文件的代码...
-(IBAction)addToPicker
{
CoreDataPickerAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = [appDelegate managedObjectContext];
NSManagedObject *thePerson = [NSEntityDescription insertNewObjectForEntityForName:@"Event" inManagedObjectContext:context];
[thePerson setValue:textField.text forKey:@"eventName"];
[context save:&error];
textField.text=@"";
self.viewDidLoad;
[textField resignFirstResponder];
}
现在我有...
- (void)viewDidLoad {
NSMutableArray *array = [[NSMutableArray alloc] init];
//code needed to send all the objects in the sqlite Core Data store into array to be read by the pickerView
self.pickerData = array; // the picker uses NSMutableArray pickerData for its data
[array release];
[super viewDidLoad];
}
任何帮助将不胜感激。 克里斯
【问题讨论】:
标签: iphone-sdk-3.0 core-data nsmutablearray uipickerview