Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RookieAppler

macrumors member
Original poster
Mar 15, 2012
58
0
Code:
		NSManagedObjectContext *ctx = [[NSManagedObjectContext alloc] init];
		[ctx setUndoManager:nil];
		
		ITMAppDelegate *appDel = (ITMAppDelegate *)[[UIApplication sharedApplication] delegate];
		[ctx setPersistentStoreCoordinator: [appDel persistentStoreCoordinator]];
		
		//self.managedObjectContext = appDelegate.managedObjectContext;
		ITMDistinctCustomers *distinctCustomer = (ITMDistinctCustomers *)[NSEntityDescription
																	insertNewObjectForEntityForName:@"ITMDistinctCustomers"
																		  inManagedObjectContext:ctx];
distinctCustomer.name=@"Blah";
...
[self.distinctCustomerArray addObject:distinctCustomer];

NSError *error = nil;
	if (![ctx save:&error])
	{
		NSLog(@"Failed to save distinct customer");
	}
I make an NSMutableArray of distinctCustomers and try to save them but it wont save. I put only this entity here. I have 10 other entities and neither saves. Please help me out. Thanks.
 
Last edited by a moderator:

RookieAppler

macrumors member
Original poster
Mar 15, 2012
58
0
@dejo.I have this tool called SQLite Manager, a firefox addon.In that tool I went to the ITMDistinctCustomers table and did "select * from ITMDistinctCustomers "and it has nothing in there.
 
Last edited:

MattInOz

macrumors 68030
Jan 19, 2006
2,760
0
Sydney
I wonder if the problem is that you're not passing the baton. You seem to be creating a new baton out of thin air in the hands of the second runner and trying to bless it as the official baton.

A quick read of the doc's and sure you can attach multiple MOC's to the same PersistentStoreCoordinator but the store uniques between the contexts. I sort of wonder if the uniquing is obscuring the created objects. Are there and objects in the file?

If your going to the appDelegate to get the PersistentStoreCoordinator anyway why not just ask it for the ManagedObjectContext instead?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.