mardi 5 janvier 2016

Swift conditional binding on array

Is there a way to use if let on an array. If the array has a value at index let it equal this value.

if let view = self.view.subviews({$0.tag == 1 })[0] {
      view.backgroundColor = UIColor.blackColor()
} else {
     print("No view with tag 1")
}

Aucun commentaire:

Enregistrer un commentaire