0

助けて!!!私は一対多の関係を持っています。

[self.menu addSubMenuObject:newSubMenu] が機能しないのはなぜですか?

ManagerCoreData * managerCoreData = (ManagerCoreData *)[ManagerCoreData sharedInstance];
NSManagedObjectContext * managedObjectContex = managerCoreData.managedObjectContext;
SubMenu * newSubMenu =(SubMenu*) [NSEntityDescription insertNewObjectForEntityForName:@"SubMenu" inManagedObjectContext:managedObjectContex];

[self.menu addSubMenuObject:newSubMenu];

if (newSubMenu != nil){

    newSubMenu.name = self.textFieldName.text;
    newSubMenu.cost = [NSNumber numberWithInteger:[self.textFieldCost.text integerValue]];
    newSubMenu.about = self.textFieldAbout.text;
    newSubMenu.imageOriginal = self.imageView.image;

          NSError * savingError = nil;
    if ([managedObjectContex save:&savingError]){
        [self.navigationController popViewControllerAnimated:YES];
    }else {
        NSLog(@"Failed to save manager object contex!!!Error %@",savingError);

    }
}else {
    NSLog(@"Failed to create new object!!!");
}



@class SubMenu;

@interface Menu : NSManagedObject

@property (nonatomic, retain) NSData * imageMiddle;
@property (nonatomic, retain) id imageOriginal;
@property (nonatomic, retain) NSData * imageSmall;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSSet *subMenu;

@end

@interface Menu (CoreDataGeneratedAccessors)

- (void)addSubMenuObject:(SubMenu *)value;
- (void)removeSubMenuObject:(SubMenu *)value;
- (void)addSubMenu:(NSSet *)values;
- (void)removeSubMenu:(NSSet *)values;

@end

*キャッチされない例外 'NSInvalidArgumentException' が原因でアプリを終了します。理由: '-[サブメニュー メニュー]: 認識されないセレクターがインスタンス 0x74caf90 に送信されました'

4

0 に答える 0