i absolutely loving realm (0.92) in combination swift have question reading object database. goal retrieve single object known, unique id (which happens primary key.
all documentation appears oriented around queries multiple objects filtered. in case know object id and, since known unique, retrieve directly.
my current approach follows:
realm().objects(book).filter("id == %@", prevbook.nextid).first
this seems heavy-handed. documentation prior versions suggest there more direct way can't seem locate in documentation.
the problem current approach is crashing exception on following function:
public func filter(predicateformat: string, _ args: cvarargtype...) -> results<t>
the exception mysteriously reported as:
exc_bad_access (code=1, address=0xedf)
any suggestions welcome.
anticipating 1 line of questioning: have confirmed replacing prevbook.nextid known, id not solve problem
object(oftype:forprimarykey:) you're looking for: realm().object(oftype: book.self, forprimarykey: prevbook.nextid)
. there's no simpler way filter().first
if need search object other primary key.
Comments
Post a Comment