Objective c 域RLMSupport中的条件位置

Objective c 域RLMSupport中的条件位置,objective-c,swift,realm,Objective C,Swift,Realm,我的android应用程序中有这些查询: RealmResults<T> results = realm.where(tClass).equalTo(key, value).findAll(); RealmResults<T> results = realm.where(tClass).findAll(); 哎呀,忘了我以前的答案吧!我忘了iOS 7上没有Realm Swift的本机版本,您需要使用Swift bridged Objective-C版本 等效代码为: l

我的android应用程序中有这些查询:

RealmResults<T> results = realm.where(tClass).equalTo(key, value).findAll();
RealmResults<T> results = realm.where(tClass).findAll();

哎呀,忘了我以前的答案吧!我忘了iOS 7上没有Realm Swift的本机版本,您需要使用Swift bridged Objective-C版本

等效代码为:

let realm = RLMRealm.defaultRealm()
let allObjects = MyObjectClass.allObjectsInRealm(realm)
let filteredObjects = allObjects.objectsWhere("key == value")
要澄清的是,
filter
方法仅在领域Swift中可用,其在Objective-C中的等效方法是
objectsWhere()
。过滤语法基于苹果的
NSPredicate
API。有关语法以及Realm查询中支持的内容的更多信息,请参阅

let realm = RLMRealm.defaultRealm()
let allObjects = MyObjectClass.allObjectsInRealm(realm)
let filteredObjects = allObjects.objectsWhere("key == value")