Göktuğ Aral
Göktuğ Aral

Reputation: 1409

'self' captured by a closure error with &&, || operator

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

Answers (1)

Mukund Sarada
Mukund Sarada

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

Related Questions