Realm.io : 保留一个枚举
Realm.io : Persist an enum
鉴于以下情况:
typedef NS_OPTIONS(NSUInteger, AssetClass)
{
AssetClassFixed = 1,
AssetClassPortable = 2
};
如何定义一个实体,该实体将以 属性 枚举类型持久化?
@interface MyEntity : RLMObject
@property AssetClass assetClass;
@end
这预计会失败:
'Can't persist property 'assetClass' with incompatible type. Add to
ignoredPropertyNames: method to ignore.'
对于 Objective-C 枚举,它不起作用的唯一原因是,因为枚举类型基于无符号类型,即 not yet supported.
如果您将其更改为有符号类型,它应该可以在没有别名的情况下工作 属性。
-typedef NS_OPTIONS(NSUInteger, AssetClass)
+typedef NS_OPTIONS(NSInteger, AssetClass)
鉴于以下情况:
typedef NS_OPTIONS(NSUInteger, AssetClass)
{
AssetClassFixed = 1,
AssetClassPortable = 2
};
如何定义一个实体,该实体将以 属性 枚举类型持久化?
@interface MyEntity : RLMObject
@property AssetClass assetClass;
@end
这预计会失败:
'Can't persist property 'assetClass' with incompatible type. Add to ignoredPropertyNames: method to ignore.'
对于 Objective-C 枚举,它不起作用的唯一原因是,因为枚举类型基于无符号类型,即 not yet supported.
如果您将其更改为有符号类型,它应该可以在没有别名的情况下工作 属性。
-typedef NS_OPTIONS(NSUInteger, AssetClass)
+typedef NS_OPTIONS(NSInteger, AssetClass)