Skip navigation.
 
mlRe: Using isMemberOfClass with a tree of subclass of NSManagedObject
FROM : Bill Bumgarner
DATE : Sat Jun 28 20:14:44 2008

On Jun 28, 2008, at 10:58 AM, Yoann GINI wrote:
> @interface root :  NSManagedObject
> @interface song :  root
> @interface artist :  root
> @interface modification :  NSManagedObject


Obj-C classes start with a capital letter, by convention.  So -- Root, 
Song, Artist, and Modification would be standard.

> -(void)dataBaseHaveChange:(NSNotification*)notification                //I 
> receive here the notification of a CoreData modification
> {
>     NSNotification*            userInfo    = [[notification userInfo] retain];


No need to -retain the userInfo.

>
>     NSSet*                objectsSet    = nil;
>     
>     objectsSet = [userInfo valueForKey:NSInsertedObjectsKey];


You want -objectForKey:  -valueForKey: is for key value coding, -
objectForKey: is for extracting objects from a dictionary.

Shouldn't cause a problem.

>
>     for (NSManagedObject* modEntry in objectsSet) {


Are you sure objectsSet contains any objects?

>
>         if ([modEntry isKindOfClass:[root class]]) {
>             //do something
>         }
>     }


b.bum