UILocalNotification crashes my application when I

2019-08-24 15:22发布

问题:

I can enable an UILocalNotification in my application, I proceed like this:

in my UIViewController

if(_endDate){    
        UILocalNotification *localNotif = [[UILocalNotification alloc] init];
        if (localNotif == nil)
            return;
        localNotif.fireDate = _endDate;
        localNotif.timeZone = [NSTimeZone defaultTimeZone];

        localNotif.alertBody = @"go";
        localNotif.soundName = UILocalNotificationDefaultSoundName;
        localNotif.applicationIconBadgeNumber = 1;

        [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
    }

in Appdelegate:

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
    application.applicationIconBadgeNumber = 0;
}

When the notification appears, I launch the app, I enter into the delegate correctly but after that, the application crash.

I work in IO6

Can you help me ?

回答1:

for fineding creash you can do this following step for profile project like:-

in Xcode-->Product-->choose profile.

wait till project runs in instruction Zombies. press on Profile you found your simulator as normal run. when your app Cresh you just select consol like:-

you found where is crash log with variable hope you got it