Your model (xcdatamodel) says what class is used for each entity, you have that 
set to the name of your custom class, right? If so it will give you the correct 
object type when you insert or retrieve it. 

executeFetchRequest:error: in NSManagedObjectContext will return an NSArray() 
of the correct subclasses of NSManagedObject. If you're using methods which are 
documented to return NSManagedObject*(s) [ can't think of one offhand ] that 
should also be actually returning the correct subclass, you just need to cast. 

On 10-Jul-2010, at 12:29 PM, Matt James wrote:

> Hi all,
> 
> In the WWDC session "Mastering Core Data", it was recommended to subclass 
> NSManagedObject, which I'm doing.  Not only does this follow their 
> recommendation, but it's also helpful for coding additional logic that might 
> be appropriate on a per-model basis.  What I don't understand, however, is 
> how to fetch those subclassed objects from the managed object context.
> 
> As an example, let's say I have PersonModel which extends NSManagedObject 
> and, for me, represents a "Person" entity.  When I run a fetch for Person 
> entities, I get back NSManagedObjects.  That's fine, but I'm unable to make 
> use of any custom logic I have on the PersonModel class.
> 
> I'm new to Core Data, so I may very well be misunderstanding the 
> recommendations or be doing things in a screwy manner.  Please straighten me 
> out!
> 
> Thanks for any help.
> 
> -Matt James
> http://www.macyenta.com_______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
> 
> This email sent to r...@rols.org

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to