0

Is it possible to map a property of a Core Data model from one type to another using only a Core Data Mapping Model or do you need to define a custom Mapping Policy?

For example lets say I have a model called Show with the property identifier of type Integer 32 and I want to map it to a String. This is just a hypothetical example. You can of course do this in code as needed in the ManagedObject subclass.

I am looking to know if it is possible in general.

4

1 回答 1

0

您始终可以以编程方式将属性从一种类型转换为另一种类型。以你给定的例子:

// in your NSManagedObject subclass
@property (nonatomic) int32_t identifier;

// someplace else
NSNumber *identifierNumber = [NSNumber numberWithInt:managedObject.identifier];
NSString *identifierString = [identifierNumber stringValue];
于 2013-10-22T10:38:02.623 回答