iPhone OS: Is there a way to set up KVO between two ManagedObject Entities?

Posted by nickthedude on Stack Overflow See other posts from Stack Overflow or by nickthedude
Published on 2010-05-27T00:44:34Z Indexed on 2010/05/27 0:51 UTC
Read the original article Hit count: 326

I have 2 entities I want to link with KVO, one a single statTracker class that keeps track of different stats and the other an achievement class that contains information about achievements. Ideally what I want to be able to do is set up KVO by having an instance of the achievement class observe a value on the statTracker class and also set up a threshold value at which the achievement instance should be "triggered"(triggering in this case would mean showing a UIAlertView and changing a property on the achievement class.)

I'd like to also set these relationships up on instantiation of the achievement class if possible

so kind of like this:

Achievement *achievement1 = (Achievement *)[NSEntityDescription insertNewObjectForEntityForName:@"Achievement" inManagedObjectContext:[[CoreDataSingleton  sharedCoreDataSingleton] managedObjectContext]];
    [achievement1 setAchievementName:@"2 time launcher"];
    [achievement1 setAchievementDescription:@"So you've decided to come back for more eh? Here are some achievement points to get you going"];
    [achievement1 setAchievementPoints:[NSNumber numberWithInt:300];
            [achievement1 setObjectToObserve:@"statTrackerInstace"
                           propertyToObserve:@"timesLaunched" 
                           valueOfPropertToSatisfyAchievement:2]

Anyone out there know how I would set this up? Is there some way I could do this by way of relationships that I'm not seeing?

Thanks,

Nick

© Stack Overflow or respective owner

Related posts about iphone

Related posts about core-data