Core data 如何更新RKObjectMapping的属性映射
因为我的核心数据对象与来自服务器的域对象相同,所以我使用以下代码自动设置映射:Core data 如何更新RKObjectMapping的属性映射,core-data,restkit,Core Data,Restkit,因为我的核心数据对象与来自服务器的域对象相同,所以我使用以下代码自动设置映射: RKObjectMapping *mapping = [RKEntityMapping mappingForEntityForName:entityClassName inManagedObjectStore:managedObjectStore]; // Get the list of attributes NSEntityDescription* entityInfo = [NSEntityDescriptio
RKObjectMapping *mapping = [RKEntityMapping mappingForEntityForName:entityClassName inManagedObjectStore:managedObjectStore];
// Get the list of attributes
NSEntityDescription* entityInfo = [NSEntityDescription entityForName:entityClassName inManagedObjectContext:managedObjectContext];
[mapping addAttributeMappingsFromArray:[[entityInfo attributesByName] allKeys]];
稍后,因为有一个属性是特定的,所以我需要更新mapping.attributeMappings数组。但我无法删除/清除旧数组,因为它是只读的。是否有任何官方的方法来更新数组?否,您通常会创建一个新的映射(通常是一个不同的响应描述符,这样您就可以在它们之间切换,而无需更改对象管理器的配置)
从技术上讲,您可以将
RKObjectMapping
子类化,或向其中添加一个类别,并修改mutablePropertyMappings
,以实现您的目标。谢谢您。认可的。