由于“功能签名专业化<arg [0] arg [2] =”爆炸“>”iOS应用程序崩溃

时间:2015-09-03 11:32:56

标签: ios swift

Crashlytics报告了多条崩溃消息:

function signature specialization <Arg[0] = Exploded, Arg[2] = Exploded>

这个例外首先意味着什么?

这是我的代码,崩溃是在闭包内的“return resultSoFar”中报告的。

private class func reduceMemberships(memberships: [HappeningMember]) -> (map: Dictionary<String, HappeningMember>, maxDateAsString: String?) {
    let maxDateAsString = Session.lastUpdatedAt
    let maxDateAsDouble = (maxDateAsString == nil) ? 0 : DateUtil.localDateFromIsoDateString(maxDateAsString!)!.timeIntervalSince1970
    let initialTuple = (map: Dictionary<String, HappeningMember>(), maxDateAsString: maxDateAsString, maxDateAsDouble: maxDateAsDouble )
    let reductionResult = memberships.reduce(initialTuple) {
        (var resultSoFar, membership) in
        let membershipUpdatedAtAsAdouble = DateUtil.localDateFromIsoDateString(membership.updatedAt)!.timeIntervalSince1970
        resultSoFar.map[membership.happening._id] = membership
        resultSoFar.maxDateAsDouble = max(membershipUpdatedAtAsAdouble, resultSoFar.maxDateAsDouble)
        resultSoFar.maxDateAsString = (resultSoFar.maxDateAsDouble == membershipUpdatedAtAsAdouble) ? membership.updatedAt : resultSoFar.maxDateAsString
        return resultSoFar // CRASHES HERE
    }
    return (reductionResult.map, reductionResult.maxDateAsString)
}

1 个答案:

答案 0 :(得分:1)

我怀疑这是因为你从完成处理程序返回。尝试使用完成处理程序而不是返回,这将使用此函数的异步方式。

private class func reduceMemberships(memberships: [HappeningMember], completion: (map: Dictionary<String, HappeningMember>, maxDateAsString: String?)) {
    let maxDateAsString = Session.lastUpdatedAt
    let maxDateAsDouble = (maxDateAsString == nil) ? 0 : DateUtil.localDateFromIsoDateString(maxDateAsString!)!.timeIntervalSince1970
    let initialTuple = (map: Dictionary<String, HappeningMember>(), maxDateAsString: maxDateAsString, maxDateAsDouble: maxDateAsDouble )
    let reductionResult = memberships.reduce(initialTuple) {
        (var resultSoFar, membership) in
        let membershipUpdatedAtAsAdouble = DateUtil.localDateFromIsoDateString(membership.updatedAt)!.timeIntervalSince1970
            resultSoFar.map[membership.happening._id] = membership
            resultSoFar.maxDateAsDouble = max(membershipUpdatedAtAsAdouble, resultSoFar.maxDateAsDouble)
            resultSoFar.maxDateAsString = (resultSoFar.maxDateAsDouble == membershipUpdatedAtAsAdouble) ? membership.updatedAt : resultSoFar.maxDateAsString
        completion(map: resultSoFar.map, maxDateAsString: resultSoFar.maxDateAsString  )
    }
    completion(map: reductionResult.map, maxDateAsString: reductionResult.maxDateAsString)
}