Custom initializer with objects

Class UserLaunch: Object{

var launch: Class1
var payload: Class2

init(launch: Class1, payload: Class2){
    self.launch = launch
    self.payload = payload
}

What is the best way to create custom initializer for Realm object? (This one isn't working, because Realm wants default init() method)

Thanks!

Answers


If you can give some default value to the properties this should work (it works for me at least):

class UserLaunch: Object{

    dynamic var launch: Class1 = Class1() //or some other default value
    dynamic var payload: Class2 = Class2() //or some other default value

    convenience init(launch: Class1, payload: Class2){
        self.init()
        self.launch = launch
        self.payload = payload
    }
}

Need Your Help

How to create Glass GDK project in IDEA?

android intellij-idea google-gdk

So far I could not find a solution to create Google Glass GDK project in IDEA, but I have to create it via Eclipse following steps