Kingdom: cannot invoke "objects" using an argument list of type "(Object.Type)"

So I have a very simple model of a book in the kingdom

class Book: Object { dynamic var title: String! dynamic var author: String! } 

And I'm trying to get all my books in a helper class:

 var userBookLibrary = [Book]() let realm = try! Realm() func getBooksFromLocalDatastore() { userBookLibrary = realm.objects(Book) } 

This line:

 userBookLibrary = realm.objects(Book) 

produces an error in the header.

Am I crazy or is this not exactly what the Realm documentation tells us?

+7
ios swift realm
source share
1 answer

realm.objects() does not return [Book] , but Results<Book>? . Therefore, you need to change the type of userBookLibrary :

 var userBookLibrary = Results<Book>? 
+11
source share

All Articles