如何在 Objective-C 中导航 Core Data 对多关系?
我有一个Event
模型,每个实例都有许多EventOccurace
通过occurances
[原文如此] 关系公开的对象。Apple 的文档说标准属性访问器应该可用,但我不断收到编译时错误:
DetailViewController.h
@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>
@property (strong, nonatomic) id detailItem;
@end
细节视图控制器.m
- (void)viewDidLoad
{
[super viewDidLoad];
NSSet * foo;
foo = [[self detailItem] occurances];
///No known instance method for selector 'occurances'
foo = self.detailItem.occurances;
///Property 'occurances' not found on object of type 'id'
//try casting to NSManagedObject to access
NSManagedObject * casted = (NSManagedObject *)self.detailItem;
foo = casted.occurances;
///Property 'occurances' not found on object of type 'NSManagedObject *'
foo = [casted occurances];
///No visible @interface for 'NSManagedObject' declares the selector 'occurances'
}