Ios CoreData更新/编辑对象属性

Ios CoreData更新/编辑对象属性,ios,objective-c,core-data,attributes,editing,Ios,Objective C,Core Data,Attributes,Editing,需要帮助编辑/更新对象属性(属性)到Coredata的新手。我可以将新对象保留到存储中并删除现有对象,但无法编辑/更新现有对象 基本上,实体的属性填充在mainTableViewController中,用户点击所选行将切换到detailViewController,并将数据填充到textfields、images和textview 如果用户选择编辑数据,它将切换到editViewController,用户可以直接从从detailViewController填充的文本字段textView编辑数据

需要帮助编辑/更新对象属性(属性)到Coredata的新手。我可以将新对象保留到存储中并删除现有对象,但无法编辑/更新现有对象

基本上,实体的属性填充在mainTableViewController中,用户点击所选行将切换到detailViewController,并将数据填充到textfields、images和textview

如果用户选择编辑数据,它将切换到editViewController,用户可以直接从从detailViewController填充的文本字段textView编辑数据

根据下面的代码,我无法编辑实体属性。请帮忙。多谢各位

- (IBAction)editLoginDoneBarButtonPressed:(UIBarButtonItem *)sender {

NSManagedObjectContext *context = [CoreDataHelper managedObjectContext];


NSEntityDescription *entity = [NSEntityDescription entityForName:@"Login" inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entity];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"loginid == %@", self.loginIDEditVC];
[request setPredicate:predicate];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"loginid" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[request setSortDescriptors:sortDescriptors];

NSError *error = nil;

Login *loginUpdate = [[context executeFetchRequest:request error:&error] objectAtIndex:0];


//edit our objects in the Model (ManagedObjectModel)

loginUpdate.name = self.editLoginNameTextField.text;
loginUpdate.image = self.editLoginImageView.image;
loginUpdate.login = self.editLoginUsernameTextField.text;
loginUpdate.password = self.editLoginPasswordTextField.text;
loginUpdate.url = self.editLoginURLTextField.text;
loginUpdate.notes = self.editLoginNotesTextView.text;


if (![context save:&error]) {
        NSLog (@"Can't update and save! %@ %@", error, [error localizedDescription]);
    }

//we need to unwindsegue
[self performSegueWithIdentifier:@"returnToLoginVC" sender:self];    }

此代码以何种方式不起作用?loginUpdate是否为非零?当编辑现有属性并点击“完成”按钮时,@TomHarrington会收到关于分配给它的警告吗。属性不会更新。在mainLoginTableViewController中,属性保持不变,就像没有进行编辑一样。@stevesliva没有警告。