【发布时间】:2013-04-02 22:35:42
【问题描述】:
如何在 Objective-C 中导航 Core Data 的多对多关系?
我有一个Event 模型,每个实例都有许多通过occurances [原文如此] 关系公开的EventOccurace 对象。 Apple 的文档说 standard property accessor should be available 但我不断收到编译时错误:
DetailViewController.h
@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>
@property (strong, nonatomic) id detailItem;
@end
DetailViewController.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'
}
【问题讨论】:
标签: objective-c core-data