简体   繁体   中英

Xcode convert crash log

How can convert the stack trace came from the Console logs? like this:

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

This crash appear in the console logs. when the user kill the app and open a local notification, previously shown.

i using this code for show a local notification:

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)")
        })

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

You can track the crash by enabling swift error breakpoints and test failure breakpoints. 在此处输入图片说明

and "(property lists cannot contain objects of type 'CFNull')" for this refer this LINK

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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