Re: Understanding CoreData
Re: Understanding CoreData
- Subject: Re: Understanding CoreData
- From: Uli Kusterer <email@hidden>
- Date: Sun, 6 Feb 2011 11:42:47 +0100
On 06.02.2011, at 00:45, Jean Cencig wrote:
> It fully works, I try to understand how, but I am lost. The NSlog messages placed in the overridden init methods of the subclassed NSArrayController and NSManagedObject never show in the Debugger Console, but the NSLog in the NSArrayController newObject method does. How can they work without being inited?
They can't. You're not giving us much information, but here are a few thoughts:
-> How are you telling your code to create objects of your subclass? My guess is you are accidentally creating objects of the base class (NSManagedObject is a rather "dynamic" class that uses the CoreData model file to decide what properties it should expose at runtime, not unlike an NSDictionary, so it might behave just right even without any code from your subclass, if there is any).
To find out if you're getting the right kind of object, use the debugger, and show the "Types" column. That'll show you the actual type of every object, not just the type of each variable.
-> Every object has to be inited. If you are not seeing an init call, that means you are either not dealing with an object (i.e. you're just using random memory that happens to look like an object, and forgot to actually create the object or remember its address properly), or you are dealing with a half-initialized object (e.g. because the object supports the NSCopying protocol, and you forgot to implement that in your subclass that adds more instance variables).
-> While an init method has to be called on an object, some classes have several init methods. While they are usually funneled through one central "designated initializer", there are cases (e.g. initWithCoder:) that by their nature require a completely independent chain of initializers up the class hierarchy. In either case, you may have overridden an init method that is just never called.
I doubt this is your case, but thought I should mention it for completeness' sake.
In closing: I think it would help if you posted relevant portions of source code and more details about your application's setup. E.g. where and how you trigger instantiation of objects, tell it to instantiate your subclasses for each of the subclasses.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden