Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift how to declare realm results?

Tags:

ios

swift

realm

How to declare Results generic

I want to declare it like global variable in UITableViewController and fill within viewDidLoad func

Here's my code

class ContactsController: UITableViewController {
    var contacts = Results<Contact>()

        override func viewDidLoad() {
            super.viewDidLoad()
            contacts = Domain.FetchContacts()
        }
}

But I get error

Cannot invoke initializer for type 'Results' with no arguments

How can I declare it?

like image 921
Damir Shakenov Avatar asked Jan 04 '23 21:01

Damir Shakenov


1 Answers

I declared results generic like this

var contacts: Results<Contact>? = nil
like image 65
Damir Shakenov Avatar answered Jan 19 '23 06:01

Damir Shakenov