【问题标题】:Realm.io : Persist an enumRealm.io:持久化一个枚举
【发布时间】:2015-03-30 08:08:15
【问题描述】:

鉴于以下情况:

typedef NS_OPTIONS(NSUInteger, AssetClass)
{
    AssetClassFixed = 1,
    AssetClassPortable = 2
};

如何定义一个实体,该实体将与枚举类型的属性一起持续存在?

@interface MyEntity : RLMObject

@property AssetClass assetClass;

@end

【问题讨论】:

    标签: ios objective-c realm


    【解决方案1】:

    这预计会失败:

    '不能持久化不兼容类型的属性'assetClass'。添加 ignorePropertyNames:要忽略的方法。'

    使用 Objective-C 枚举,它不起作用的唯一原因是,因为枚举类型基于无符号类型,即not yet supported

    如果您将其更改为签名类型,它应该可以在没有别名属性的情况下工作。

    -typedef NS_OPTIONS(NSUInteger, AssetClass)
    +typedef NS_OPTIONS(NSInteger, AssetClass)
    

    【讨论】:

      猜你喜欢
      • 2010-10-04
      • 1970-01-01
      • 1970-01-01
      • 2010-10-15
      • 1970-01-01
      • 1970-01-01
      • 2011-01-20
      • 2011-10-14
      • 1970-01-01
      相关资源
      最近更新 更多