线程5:同时访问0x10b883638,但修改需要独占访问
Posted
技术标签:
【中文标题】线程5:同时访问0x10b883638,但修改需要独占访问【英文标题】:Thread 5: Simultaneous accesses to 0x10b883638, but modification requires exclusive access 【发布时间】:2019-10-28 09:13:48 【问题描述】:我已经询问了this question regarding some Apple 代码并使其工作。
我有looked here,但那里的答案并不能解决我的问题 虽然我解决了这个问题,但我没有在显示的行上收到以下错误。
private var playerItemContext = 0
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?)
// Only handle observations for the playerItemContext
print("jdslfhjkfdhaldfahjkflhajfldashkjfdshkjlas")
guard context == &playerItemContext else
super.observeValue(forKeyPath: keyPath, of: object,change: change, context: context)
return
...
为什么会这样,我该如何解决?
【问题讨论】:
Simultaneous accesses to 0x1c0a7f0f8, but modification requires exclusive access error on Xcode 9 beta 4的可能重复 我看过那个问题,答案很旧,不能解决我的问题@Xcoder 你在那个问题上试过这个特定的答案吗? ***.com/a/47438532/243192 是的,它对我没有任何改变。 @wvteijlingen 【参考方案1】:试试这个代码:
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?)
// Only handle observations for the playerItemContext
guard context == &P2SheetViewController.playerStatusContext else
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
return
if keyPath == #keyPath(AVPlayer.status)
let status: AVPlayer.Status
if let statusNumber = change?[.newKey] as? NSNumber
status = AVPlayer.Status(rawValue: statusNumber.intValue)!
else
status = .unknown
//Switch over status value
switch status
case .readyToPlay:
break
// Player item is ready to play
case .failed:
print(".UKNOWN")
break
// Player item failed. See error.
case .unknown:
print(".UKNOWN")
break
// Player item is not yet ready.
@unknown default: //new jul 17
print(".UKNOWN")
break
希望对你有帮助
【讨论】:
以上是关于线程5:同时访问0x10b883638,但修改需要独占访问的主要内容,如果未能解决你的问题,请参考以下文章