NSArrays will only accept objects, so the first step is to turn your NSInteger into NSNumber using this method:
+ (NSNumber *)numberWithInt:(int)value
So:
NSNumber *myNumber = [NSNumber numberWithInt:marbles];
and then you can:
[records setValue:myNumber forKey:@"marbles"];
Basically, as soon as you retrieve the data, you get a managed ObjectContext object, consider it a drawing board, and any changes (including adding or deleting new objects) that you make for these objects can be saved again in CoreData using something like this
NSError *error; if (![context save:&error]) {
Where context is the context that you will get with NSFetchedResultsController. What you can do like this:
NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
I would recommend taking a look at the Master Data Programming Guide.
source share