[newVehicle setValue: _txtFieldVehicleNumber.text forKey:@"number"];
[newVehicle setValue: lblFuelType.text forKey:@"fueltype"];
[newVehicle setValue: lblFuelUnit.text forKey:@"fuelunit"];
[newVehicle setValue: lblDistanceUnit.text forKey:@"distanceunit"];
我想更新名为Vehicle"的核心数据实体,对于该实体,我有几个属性,当我从实体中选择特定属性时,我想更新其中一些属性,但不是全部.那我该怎么办??
I want to update my core data entity named "Vehicle", for that entity I have several attributes and I want to update some of them but not all when I select particular attribute from the entity. So what should I do ??
您可以执行以下操作(近似代码.实现错误处理和检查语法).
you can do the following (approximate code. Implement error handling and check syntax).
NSFetchRequest *fetchRequest=[NSFetchRequest fetchRequestWithEntityName:@"Vehicle"];
NSPredicate *predicate=[NSPredicate predicateWithFormat:@"vehicle_id==%@",vehicle_id]; // If required to fetch specific vehicle
fetchRequest.predicate=predicate;
Vehicle *newVehicle=[[self.managedObjectContext executeFetchRequest:fetchRequest error:nil] lastObject];
[newVehicle setValue: _txtFieldVehicleNumber.text forKey:@"number"];
[newVehicle setValue: lblFuelType.text forKey:@"fueltype"];
[newVehicle setValue: lblFuelUnit.text forKey:@"fuelunit"];
[newVehicle setValue: lblDistanceUnit.text forKey:@"distanceunit"];
[self.managedObjectContext save:nil]
这篇关于如何更新核心数据输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!