Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • Optional can be safely unwrapped inside the while loop Commented Mar 23, 2016 at 12:53
  • 1
    I updated my answer to use an implicit optional instead of an explicit one. Commented Mar 23, 2016 at 12:58
  • This will crash when parentView becomes nil finally. You can leave it as it was before, or unwrap the optional inside the while loop Commented Mar 23, 2016 at 13:00
  • It doesn't crash on the IBM Swift Sandbox 3.0-dev. The code I tested is here. Commented Mar 23, 2016 at 13:01
  • 1
    not nice :/ we declare variable outside of the loop, make iteration in the end of code block, and at all have too many lines of code Commented Mar 23, 2016 at 13:37