Skip navigation.
 
mlRe: Using isMemberOfClass with a tree of subclass of NSManagedObject
FROM : mmalc crawford
DATE : Sat Jun 28 19:32:12 2008

On Jun 28, 2008, at 10:15 AM, Owen Yamauchi wrote:
>
> On Jun 28, 2008, at 9:58 AM, Yoann GINI wrote:

>>     I've a CoreData base with some kind of object what are a subclass 
>> of an abstract class called "root" (root is a subclass of 
>> NSManagedObject). In a part of my code I need to catch all 
>> operation on object what are a child of root. For do that I use the 
>> notification NSManagedObjectContextObjectsDidChangeNotification and 
>> I would use "isMemberOfClass" method for test each objet. I don't 
>> know why but this method always return "NO" even of an object what 
>> are a chlid of root...
>>

> Use -isKindOfClass: instead. -isMemberOfClass: only tells you if an
> object is an instance of that specific class. -isKindOfClass: includes
> all superclasses as well.
>

isKindOfClass: includes all *subclasses* as well.

You should almost certainly, though, not be using class-based tests -- 
you should instead test the entity of the managed object (if you need 
to test for subentities, use isKindOfEntity).

mmalc