views:

1066

answers:

1

I'm new to IPhone development and I'm currently trying my hand at Core Data. I have a couple entities that I've defined in my model. In one entity I have a fetched property. When I generate the Objective-C source files from my model, my entity that I defined with the fetched property does not have a property defined for the fetched property. Why? How do I access the fetched property?

More details in response to Tim:

I have an entity named Library and another entity named Book. Library has a one to many relationship to Book (Book also has an inverse relationship). Book has a BOOL property called isCheckedOut. I defined a fetched property on Libray called fetchAllCheckedOutBooks. The destination entity is Book and the predicate is isCheckedOut == 1

+1  A: 

Have you tried using valueForKey: and passing in the name of your fetched property? That's how I would expect it to work. I would also expect that it would return an NSSet object, but that's easily verified by doing this:

id results = [myManagedObject valueForKey:@"fetchedPropertyName"];
NSLog(@"%@", [results className]);
Dave DeLong
-1 fetched properties return NSArray not NSSethttp://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html#//apple_ref/doc/uid/TP40001857-SW7A fetched property is represented by an array, not a set. The fetch request associated with the property can have a sort ordering, and thus the fetched property may be ordered.
groundhog