Reputation: 1409
I have a initialize method. Why do I see 'self' captured by a closure before all members were initialized if I use && or || operand.
var type:Type? = .non
init(dictionary:[String:AnyObject]){
if let type = dictionary["type"] as? Int {
self.type = Type.init(rawValue: type)!
}
//'self' captured by a closure before all members were initialized
if self.type == .picture || self.type == .textWithPicture {
//........
}
}
Upvotes: 0
Views: 176
Reputation: 156
Are you inheriting your class from NSObject? If yes, you need to call super's init method before using this class's properties.
Upvotes: 3