与NSString的阵列RLMObject [英] RLMObject with Array of NSStrings

查看:505
本文介绍了与NSString的阵列RLMObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经升级项目中使用领域的持久性存储,我无法找到如何在我的车型之一使用字符串数组的任何文件。

I've been upgrading a project to use Realm as the persistence store and I'm not able to find any documentation on how to use an array of strings in one of my models.

对于RLMObject数组的实现是其中T继承RLMObject使用一个RLMArray

The implementation of an Array for a RLMObject is to use an RLMArray where T inherits RLMObject

我可以做一个继承财产..里面是字符串对象......但看起来颇有些开销替换字符串的一个NSArray。

I could make an object that inherits.. property inside which is string... but that seems like quite some overhead to replace an NSArray of strings.

有谁知道这样做的建议的最佳实践?

Does anyone know the recommended best practice to do this?

推荐答案

目前,您需要包含字符串的RLMObject:

You do currently need an RLMObject which contains the string:

@interface StringObject : RLMObject
@property NSString *value;
@end
RLM_ARRAY_TYPE(StringObject)

@implementation StringObject
@end

@interface Object : RLMObject
@property RLMArray<StringObject> *array;
@end

这有可能在未来的 RLMArray&LT; NSString的&GT; 将得到支持,但它只是一个更方便的接口(存储和性能明智有一个从没有显著的开销包含的对象)。

It's possible that in the future RLMArray<NSString> will be supported, but it would be just a more convenient interface (storage and performance-wise there's no significant overhead from the containing object).

这篇关于与NSString的阵列RLMObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆