小编Vic*_*tor的帖子

RLMArray - 从Object检索数组

我的模特:

Conv.h

#import <Realm/Realm.h>
#import "ConvText.h"

@interface Conv : RLMObject

@property NSInteger c_id;
@property RLMArray<ConvText> *cts;

@end
Run Code Online (Sandbox Code Playgroud)

ConvText.h

#import <Realm/Realm.h>

@interface ConvText : RLMObject

@property NSInteger ct_id;
@property NSInteger time;

@end

RLM_ARRAY_TYPE(ConvText)
Run Code Online (Sandbox Code Playgroud)

当我试图从Conv中提取ConvTexts时:

Conv *c = [Conv objectsWhere:@"c_id = %@",@(1)];
ConvText *ct = [c.cts arraySortedByProperty:@"time" ascending:NO][0]; <--
Run Code Online (Sandbox Code Playgroud)

我收到此消息:'RLMException',原因:'此方法只能在从RLMRealm检索到的RLMArray实例中调用'

我也尝试这样:

RLMArray *cts = c.cts;
ConvText *ct = [cts arraySortedByProperty:@"time" ascending:NO][0];
Run Code Online (Sandbox Code Playgroud)

objective-c realm ios

0
推荐指数
1
解决办法
2139
查看次数

标签 统计

ios ×1

objective-c ×1

realm ×1