NSCFConstantString text]:发送到实例的无法识别的选择器
NSManagedObjectContext *context = [self managedObjectContext];
if (self.device) {
// Update existing device
[self.device setValue:self.nameTextField.text forKey:@"name"];
[self.device setValue:self.versionTextField.text forKey:@"version"];
[self.device setValue:self.companyTextField.text forKey:@"company"];
NSLog(@"if");
} else {
// Create a new device
NSManagedObject *newDevice = [NSEntityDescription insertNewObjectForEntityForName:@"Device" inManagedObjectContext:context];
[newDevice setValue:self.nameTextField.text forKey:@"name"];
[newDevice setValue:self.versionTextField.text forKey:@"version"];
[newDevice setValue:self.companyTextField.text forKey:@"company"];
NSLog(@"else");
}
NSError *error = nil;
// Save the object to persistent store
if (![context save:&error]) {
NSLog(@"Can't Save! %@ %@", error, [error localizedDescription]);
}
答案 0 :(得分:0)
NSCFConstantString text]:发送到实例的无法识别的选择器
错误表明您尝试在text
上设置NSString
。
因此,检查您的代码并查看是否要访问text
上的NSString
属性,因为NSString
没有text
属性并更正了。
希望这会有所帮助!