Simultaneous accesses to 0x1c0a7f0f8, but modification requires exclusive access error on Xcode 9 beta 4

后端 未结 11 1839
孤城傲影
孤城傲影 2020-11-29 05:15

my project uses both Objective-C and Swift code. When a user logs in, it calls a set of apis for user preference, I have a DataCoordinator.swift class which schedules the AP

11条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 05:52

    Swift 5 here. I was calling a function from a property didSet and testing another property from the same object and I got this error.

    I fixed it by calling my function from within another thread:

    DispatchQueue.global(qos: .userInitiated).async {
        // do something
    }
    

    Basic fix but it works.

提交回复
热议问题