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

MarkoSan

macrumors newbie
Original poster
Sep 3, 2009
1
0
Hi to all!

I have following problem: Once i try to create new class NSEntityDescription via:
Code:
	NSEntityDescription *entity=[NSEntityDescription entityForName:GAMES_ENTITY
											inManagedObjectContext:managedObjectContext];
where
Code:
static NSString *GAMES_ENTITY=@"Game";	// games table name
I always get null pointer after statement execution. I've set up the 'Game' table (entity) via Data Model GUI Designer. After that I've filled up table with 2 recors. The database type is SQLite and I succesfully create persistent coordinator for this database type.

Well, I think I know why entity is empty. In my code, I have following chunck:
Code:
/**
 Returns the managed object model for the application.
 If the model doesn't already exist, it is created by merging all of the models found in the application bundle.
 */
- (NSManagedObjectModel *)managedObjectModel
{
   if (managedObjectModel!=nil)
	{
        return managedObjectModel;
    }
    managedObjectModel=[[NSManagedObjectModel mergedModelFromBundles:nil] retain];
    return managedObjectModel;
}
Now, I my bundle is empty (I think - where do I check or better, how do I create bundle with entities from .xcdatamodel file?) and therefore managedObjectModel's entities array is empty (am I right?). How do I get entities directly from my .xcdatamodel file??
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.