My managed object has a relationship called items
. My subclass has a method called itemCount
. Unfortunatly my attempts to get the object count in the items relationship always returns 0. Here's the relevant code:
@interface List : NSManagedObject {}
@property (nonatomic, retain) NSSet* items;
@property (nonatomic, readonly) NSNumber * itemCount;
@end
@implementation List
@dynamic items;
- (NSNumber *)itemCount
{
NSNumber * tmpValue;
NSSet *items = self.items;
if (items = nil) {
return 0;
}
tmpValue = [NSNumber numberWithInt:[items count]];
return tmpValue;
}
@end
When I walk through the itemCount method it appears to work just fine, but the self.items
counts always return zero objects. Any ideas?