Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Firebase crashlytics报告了许多<;编译器生成>;在我的生产构建中,第0行崩溃,这些崩溃是真的吗?_Ios_Swift_Crash_Firebase Crash Reporting - Fatal编程技术网

Ios Firebase crashlytics报告了许多<;编译器生成>;在我的生产构建中,第0行崩溃,这些崩溃是真的吗?

Ios Firebase crashlytics报告了许多<;编译器生成>;在我的生产构建中,第0行崩溃,这些崩溃是真的吗?,ios,swift,crash,firebase-crash-reporting,Ios,Swift,Crash,Firebase Crash Reporting,我在swift项目中使用websocket,从最近几周开始,我收到了此类崩溃: 第0行 有人知道这件事吗 Channel.TMLock.sync { var idx = 0 for msg in Channel.trackedMsgs { mt = msg if msg.isResponseTo(responseMessage: responseMessage) { Channel.trackedMsgs.remove(at

我在swift项目中使用websocket,从最近几周开始,我收到了此类崩溃:

第0行

有人知道这件事吗

Channel.TMLock.sync {
    var idx = 0
    for msg in Channel.trackedMsgs {
        mt = msg
        if msg.isResponseTo(responseMessage: responseMessage) {
            Channel.trackedMsgs.remove(at: idx) -> Removing elements while iteration will cause crash
            break
        }

        idx += 0
    }
}
您可以将其改写为:

Channel.TMLock.sync {
        var idx = 0
        var indexOfElement = 0
        while indexOfElement < Channel.trackedMsgs.length{
        mt = msg
        if msg.isResponseTo(responseMessage: responseMessage) {
                Channel.trackedMsgs.remove(at: idx)
                break
            }

            idx += 0
            indexOfElement += 1
        }
    }
Channel.TMLock.sync{
var idx=0
var indexOfElement=0
而indexOfElement
如果您附加包含Channel.swift:137行的方法代码,我们可能会假设出了什么问题。@NazarLisovyi为了更好地理解,我添加了更多代码。显然,您希望删除索引超出范围的元素。这种逻辑看起来wrong@NazarLisovyi我也假设了同样的原因,但我只是不理解()连接的连接。是的,
第0行在Swift stacktraces中是真实存在的。签出此问题中的详细信息:。
Channel.TMLock.sync {
    var idx = 0
    for msg in Channel.trackedMsgs {
        mt = msg
        if msg.isResponseTo(responseMessage: responseMessage) {
            Channel.trackedMsgs.remove(at: idx) -> Removing elements while iteration will cause crash
            break
        }

        idx += 0
    }
}
Channel.TMLock.sync {
        var idx = 0
        var indexOfElement = 0
        while indexOfElement < Channel.trackedMsgs.length{
        mt = msg
        if msg.isResponseTo(responseMessage: responseMessage) {
                Channel.trackedMsgs.remove(at: idx)
                break
            }

            idx += 0
            indexOfElement += 1
        }
    }