views:

19

answers:

1

When I have a subclass of NSManagedObject, I could do this:

Friend *newFriend = (Friend*)[[NSManagedObject alloc] initWithEntity:@"Friend" 
                                          insertIntoManagedObjectContext:moc];

But since I have a subclass, couldn't I simply instantiate it another way so that I don't have to tell it what Entity it is? (I mean: Is there already an predefined initializer for this, or must I write my own?)

+1  A: 

Besides initWithEntity:insertIntoManagedObjectContext: the only two methods you can use to customize object initialization are awakeFromInsert and awakeFromFetch. See the full discussion related to Core Data object initialization here.

unforgiven
But I could write an additional convenience method that would just call internally the -initWithEntity:insertIntoManagedObjectContext: method for me, right?
dontWatchMyProfile
Yes, the question is: why would you want to do this?
unforgiven