public class User : NSObject {
var id: Int //will throw an error during build
var name: String?
override init(){
}
convenience init(id: Int, name: String?){
self.id = id
self.name = name
}
}
I want to create a user class. The id
should non-optional. However, my above code does not work unless I change the line to:
var id: Int = 0
I don't want to do this. Is there a better way?