繁体   English   中英

Xcode转换崩溃日志

[英]Xcode convert crash log

如何转换来自控制台日志的堆栈跟踪? 像这样:

*** 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
    }
}

您可以通过启用快速错误断点和测试故障断点来跟踪崩溃。 在此处输入图片说明

和“((属性列表不能包含'CFNull'类型的对象)”)为此,请参考此链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM