How to check for nil in while loop in Swift? I\'m getting error on this:
nil
var count: UInt = 0 var view: UIView = self while view.superview != nil { /
The syntax of while allows for optional binding. Use:
while
var view: UIView = self while let sv = view.superview { count += 1 view = sv }
[Thanks to @ben-leggiero for noting that view need not be Optional (as in the question itself) and for noting Swift 3 incompatibilities]
view
Optional