9

I was playing around with Swift, and have this code in a playground

class Foo {
    let value: String
    init(value: String!)
    {
        self.value = value
    }
}

let x : String? = nil
let foo = Foo(value: x)

The bottom line should throw an exception in the initializer, because I am unwrapping x which is nil. However I am not able to see the exception message or the fact that an error happens at runtime. If I add code below this, it does not get run (no output gets shown).

How can I see the exceptions that are thrown at runtime in a Swift playground ?

driis
  • 161,458
  • 45
  • 265
  • 341

2 Answers2

6

Click the Assistant Editor icon to open the Console Output panel.

The error is listed there.

Cezary Wojcik
  • 21,745
  • 6
  • 36
  • 36
4

As of Xcode 6.0 Beta 5, exceptions will now show up with an error marker in the source editor and in the result sidebar. If you press the quicklook button in the result sidebar we will show you the full backtrace of the exception.

Rick Ballard
  • 4,765
  • 2
  • 19
  • 17