编译发布时的奇怪错误是什么?

时间:2017-07-29 00:29:27

标签: swift

我的代码中的这一行是我的应用程序仅在发布版本上崩溃的地方。

self.setup.monthByInt = [1:"January", 2:"February", 3:"March", 4:"April", 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", 10:"October", 11:"November", 12:"December"]

func updateMonthArrayForCircle(){
    self.setup.monthByYear = ["January":0, "February":0, "March":0, "April":0, "May":0, "June":0, "July":0, "August":0, "September":0, "October":0, "November":0, "December":0]
    self.setup.monthByInt = [1:"January", 2:"February", 3:"March", 4:"April", 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", 10:"October", 11:"November", 12:"December"]
}

self.setup引用了一个结构,我将原始数组与[Int:String]初始化对象中的相同值存储起来。

struct initialize {
    let largeFrame: CGRect = CGRect(x: 0, y: 0, width: 130, height: 130)
    let smallFrame: CGRect = CGRect(x: 15, y: 25, width: 100, height: 100)
    let screenSize: CGRect = UIScreen.main.bounds

    var month: [String] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
    var monthByYear: [String:Int] = ["January":0, "February":0, "March":0, "April":0, "May":0, "June":0, "July":0, "August":0, "September":0, "October":0, "November":0, "December":0]
    var monthPure: [String] = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

    var monthByInt: [Int:String] = [1:"January", 2:"February", 3:"March", 4:"April", 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", 10:"October", 11:"November", 12:"December"]
    var intByMonth: [String:Int] = ["January":1, "February":2, "March":3, "April":4, "May":5, "June":6, "July":7, "August":8, "September":9, "October":10, "November":11, "December":12]
    var monthIndex: Int = 7
}

代码在调试模式下工作正常。

错误:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

好的,所以问题的原因是因为你正在使用转义闭包。该函数在调用完成处理程序之前返回。

以下是解决方案:

window.dataLayer