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)
}
答案 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)
}