gpt4 book ai didi

ios - EXC_BAD_ACCESS KERN_INVALID_ADDRESS iOS 11.2 Swift 4.0

转载 作者:行者123 更新时间:2023-11-30 11:39:38 25 4
gpt4 key购买 nike

仅在 iOS 11.2 中,我在以下代码中遇到崩溃。我正在使用快速4.0。我尝试调试几个小时来重现崩溃,但未能成功。这是代码

func prepareNewConnection(conn:String) -> RTCPeerConnection {

let uuid = UIDevice.current.identifierForVendor?.uuidString

localAudioTrack = peerConnectionFactory.audioTrack(withTrackId: uuid!)

mediaStream = peerConnectionFactory.mediaStream(withStreamId: LOCAL_MEDIA_STREAM_ID)
if(localAudioTrack != nil && mediaStream != nil)
{
mediaStream.addAudioTrack(localAudioTrack!) //Crash on this line
}

let pc = peerConnectionFactory.peerConnection(with: rtcConfig, constraints: mediaConstraints, delegate: self)
if(mediaStream != nil)
{
pc.add(mediaStream)
}

return pc;
}

这是 crashlytics 报告。

enter image description here

我将非常感谢任何帮助。

最佳答案

请避免安全地打开包装,使用 if let ..

 func prepareNewConnection(conn:String) -> RTCPeerConnection {

if let uuid = UIDevice.current.identifierForVendor?.uuidString {
localAudioTrack = peerConnectionFactory.audioTrack(withTrackId: uuid) //removed safely Unwrapping
mediaStream = peerConnectionFactory.mediaStream(withStreamId: LOCAL_MEDIA_STREAM_ID)
let pc = peerConnectionFactory.peerConnection(with: rtcConfig,constraints: mediaConstraints, delegate: self)
if(localAudioTrack != nil && mediaStream != nil)
{
mediaStream.addAudioTrack(localAudioTrack)
pc.add(mediaStream)
}
}
return pc
}

关于ios - EXC_BAD_ACCESS KERN_INVALID_ADDRESS iOS 11.2 Swift 4.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49397580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com