IPhone Core Objects Added to NSMutableArray

I am trying to add a bunch of Core Data objects (NSStrings) to NSMutableArray so that I pickerView can use strings as my data values.

Currently, I can save rows from a text field one at a time to the sqlite file in Core Data.

I'm having trouble extracting these objects from the sqlite Core Data file and into the NSMutable array.

This is the code for adding objects to 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];
}

Now I have ...

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

}

Any help would be greatly appreciated. Chris

+3
source share
1 answer

NSFetchRequest . - . .

NSArray *array = [moc executeFetchRequest:request error:&error];
+3

Source: https://habr.com/ru/post/1732700/


All Articles