Semaphore_wait_trap when accessing a singleton class using Swift

I am having a strange problem. I can only access singleton instances once, but if I try to access it again, it just appears. Here is a simple version of the code:

private let _SharedInstance = MyManager()

class MyManager: NSObject {

    class var sharedInstance: MyManager {
        return _SharedInstance
    }

    override init() {
        super.init()

        println("init")

        println(self.accessToken())
        println(MyManager)
        println("test 1")
        println(MyManager.sharedInstance)
        println("test 2")
    }

}

In this case, he calls it from itself init, but it happens elsewhere.

The code never gets in test 2. As soon as he turns to MyManager.sharedInstance, he freezes. No errors or warnings.

If I pause the debugger, I see that it currently matters semaphore_wait_trap

Image (names of difference classes):

Stack trace

Restarting Xcode or the computer did not help.

+4
source share
1 answer

MyManager , . init. , , .

. init. _SharedInstance init .

+8

All Articles