@implementation FirstScene
...
- (void)nextScene {
Meetings *meetings = (Meetings *) [NSEntityDescription insertNewObjectForEntityForName:@"Meetings" inManagedObjectContext:self.managedObjectContext];
NSManagedObjectID* objectID = [meetings objectID];
[secondScene setObjectID:objectID];
}
...
@end
@implementation SecondScene
....
- (void)viewDidLoad
{
[super viewDidLoad];
self.managedObjectContext = [(STAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
}
+ (void)setObjectID:(NSManagedObjectID*)objectID {
NSManagedObjectContext *context = [self managedObjectContext]; // ERROR
Meetings *theSameMeetings = (Meetings *)[context objectWithID:objectID];
}
...
@end
我在以下代码中收到错误“选择器'managedObjectContext'没有已知的类方法:
NSManagedObjectContext *context = [self managedObjectContext];
我这里的目标是将FirstScene 中的*meetings (managedObjectContext) 的objectID 传递给SecondScene,这样我就可以继续添加实体*meetings 属性。谢谢。