简体   繁体   中英

Realm, query for objects in realm using swift

I'm working on a swift project and when I look around the internet in most cases you can query for an object like so:

object.objectsWhere("parentId = 1") or such. However the objectsWhere func is not available to me, I can however use allObjects or allObjectsInRealm just fine.

The project is iOS7 in swift, working in xcode 6.3 beta Couldn't find the method in stable xcode neither if that matters. Importing realm through Pods like such:

pod 'Realm'

Any thoughts?

Edit: object in this case could be the class extending RLMObject or a typealias of it in a generic func, but it's not even there without generics.

Realm uses Objective-C variadic arguments for the +[RLMObject objectsWhere:(NSString *)predicateFormat, ...] method, which aren't supported in Swift. This is why Realm offers a file which adds a few Swift conveniences ( RLMSupport.swift ) which you can drag into your project.

Realm's installation instructions covers this and can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM