2 Replies
      Latest reply on Mar 20, 2019 12:25 PM by sHanakam
      sHanakam Level 1 Level 1 (0 points)

        var timer = Timer()



        Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x0).

        The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.







        Could anyone help me please!

        • Re: Timer in Xcode Playground
          eskimo Apple Staff Apple Staff (13,935 points)

          I test this out I created a new playground from Xcode 10.1’s macOS > Blank template.  And lo! it does crash.

          Clicking on the Quick Look button, I see a backtrace that indicates that this isn’t a problem with the timer per se, but rather a problem with the playground’s logging support.  So, rather than try to debug that, I thought I’d post a working example:

          import Foundation
          import PlaygroundSupport
          PlaygroundPage.current.needsIndefiniteExecution = true
          var bottleCount = 99
          let timer = Timer.scheduledTimer(withTimeInterval: 3.0, repeats: true) { _ in
              print("\(bottleCount) bottles of beer on the wall")
              bottleCount -= 1

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"