Xcode转换崩溃日志

时间:2018-04-12 09:56:50

标签: ios xcode

如何转换堆栈跟踪来自Console日志?像这样:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'unable to serialize userInfo: Error Domain=NSCocoaErrorDomain Code=3851 "Property list invalid for format: 200 (property lists cannot contain objects of type 'CFNull')" UserInfo={NSDebugDescription=Property list invalid for format: 200 (property lists cannot contain objects of type 'CFNull')}'
*** First throw call stack:
(0x184f83164 0x1841cc528 0x18eda82ec 0x18ea87050 0x18ea86918 0x18e79d588 0x18e7a2a14 0x18ea3e2a8 0x18ed16100 0x18ea3df0c 0x18ea3e76c 0x18f1c37c0 0x18f1c3664 0x18ef312cc 0x18f0ca3cc 0x18ef3117c 0x18ed15760 0x18e7a1158 0x18ebb6dbc 0x1876461f0 0x18764eaf8 0x184902a14 0x18490a200 0x18767a7f8 0x18767a49c 0x18767aa38 0x184f2b77c 0x184f2b6fc 0x184f2af84 0x184f28b5c 0x184e48c58 0x186cf4f84 0x18e5a15c4 0x10111ec1c 0x18496856c)

此崩溃出现在控制台日志中。当用户终止应用并打开之前显示的本地通知时。

我使用此代码显示本地通知:

let content = UNMutableNotificationContent()
content.title = title
content.subtitle = subTitle
content.body = body
content.sound = UNNotificationSound.default()
if(userinfo != nil){
   content.userInfo = userinfo!
}
content.badge = (UIApplication.shared.applicationIconBadgeNumber + 1) as NSNumber;

let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)

 let request = UNNotificationRequest.init(identifier: id, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: { (error) in
            print("UNMutableNotificationContent: \(error)")
        })

AppDelegate:

func userNotificationCenter(_ center: UNUserNotificationCenter,
                                willPresent notification: UNNotification,
                                withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        saveLog(log: "userNotificationCenter:1..> \(notification.request.identifier)")
        createObjectFromNotification(userInfo: notification.request.content.userInfo as? [String : AnyObject])

        completionHandler([.alert,.badge, .sound])
    }

    //Called to let your app know which action was selected by the user for a given notification.
    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                didReceive response: UNNotificationResponse,
                                withCompletionHandler completionHandler: @escaping () -> Void) {
        saveLog(log: "userNotificationCenter:2..> \(response.notification.request.identifier)")
        createObjectFromNotification(userInfo: response.notification.request.content.userInfo as? [String : AnyObject])

        // Print full message.
        completionHandler()
    }
func createObjectFromNotification(userInfo: [String: AnyObject]?){
    if(userInfo != nil && userInfo![UserInfo.TYPE.rawValue] != nil){
        let type = userInfo![UserInfo.TYPE.rawValue] as! Int
    }
}

1 个答案:

答案 0 :(得分:0)

您可以通过启用快速错误断点和测试失败断点来跟踪崩溃。enter image description here

和"(属性列表不能包含' CFNull'类型的对象)"为此,请参阅此LINK