[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模板网!
出现键盘时如何在iOS上调整UITextView的大小?How to resize UITextView on iOS when a keyboard appears?(出现键盘时如何在iOS上调整UITextView的大小?)
如何可靠地检测 iOS 9 上是否连接了外部键盘?How to reliably detect if an external keyboard is connected on iOS 9?(如何可靠地检测 iOS 9 上是否连接了外部键盘?)
如何在 iOS 7 上模拟键盘动画以添加“完成"数How to mimic Keyboard animation on iOS 7 to add quot;Donequot; button to numeric keyboard?(如何在 iOS 7 上模拟键盘动画以添加“完成数字键
如何关闭 iOS 键盘?How do I dismiss the iOS keyboard?(如何关闭 iOS 键盘?)
是否可以在 ios 越狱后使用外部键盘模拟触摸事件Is possible to simulate touch event using an external keyboard on ios jailbroken?(是否可以在 ios 越狱后使用外部键盘模拟触摸事件?)
如何从 iOS 应用程序上的自定义键盘检索击键?How do I retrieve keystrokes from a custom keyboard on an iOS app?(如何从 iOS 应用程序上的自定义键盘检索击键?)