0
Crashlytics
服务报告中的一些碰撞(约30坠毁/ 18的用户为1000届)NSDateFormatter dateFromString崩溃
这里我的代码:
var brutDate: String = ""
brutDate <- map["send_date"]
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
date = dateFormatter.dateFromString(brutDate)! // here is the crash (this is line 42)
系统崩溃日志是:
Crashed: NSOperationQueue 0x170422a80 :: NSOperation 0x170257190 (QOS: UTILITY)
0 AppName 0x100085f84 specialized SNotification.mapping(Map) ->() (SNotification.swift:42)
1 AppName 0x100084ff4 SNotification.mapping(Map) ->() (SNotification.swift:29)
2 AppName 0x100085a78 protocol witness for Mappable.mapping(Map) ->() in conformance SNotification (SNotification.swift:29)
在这种情况下, brutDate值是2017-01-31 20:02:08
我不是能够使应用程序崩溃一个我的手机...
编辑:我在法国和应用程序部署为加拿大,有没有Locale
问题?
任何感叹号都可能导致应用程序崩溃。了解如何安全地处理选项。 – vadian
为什么不使用,如果让或警卫来处理可选的向下转换.. ?? – Tuhin
是的,我知道这是另一个问题。如果未设置日期变量,则日期将为零。 –