https://github.com/apple/swift-evolution/blob/master/proposals/0176-enforce-exclusive-access-to-memory.md 在這個環節,你可以看到& KVOContext衝突
這樣的:
// CONFLICT. Passing 'x' as an inout argument is a write access for the
// duration of the call. Passing the same variable twice means performing
// two overlapping write accesses to that variable, which therefore conflict.
swap(&x, &x)
extension Int {
mutating func assignResultOf(_ function:() -> Int) {
self = function()
}
}
我解決它通過
我的代碼是
class Paired {
var pair = Pair(x : "PullToRefreshKVOContext")
}
let objects = Paired()
override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if (context == &objects.pair.x && keyPath == contentOffsetKeyPath && object as? UIScrollView == scrollView) {
...
}
你解決了這個問題嗎? – Glenn
[可同時訪問0x1c0a7f0f8,但修改需要Xcode 9 beta 4上的獨佔訪問錯誤](https://stackoverflow.com/questions/45415901/simultaneous-accesses-to-0x1c0a7f0f8-but-modification-requires-exclusive -訪問) – the4kman