Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8314221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:44:46+00:00 2026-06-08T20:44:46+00:00

My code throws the following exception: Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason:

  • 0

My code throws the following exception:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]' 

On the line:

[[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationMonday];

In the code block:

if ([[defaults objectForKey:@"dailyReminder"] isEqualToString:@"1"]){
        //Schedule Notifications for each checked day
        if ([[defaults objectForKey:@"dailyReminderMonday"] isEqualToString:@"1"])
        {
            //Set up the local notification
            appDelegate.dailyNotificationMonday = [[UILocalNotification alloc] init];
            if(appDelegate.dailyNotificationMonday){
                //Set fire date to alert time
                appDelegate.dailyNotificationMonday.fireDate = mondayFireTime;
                //Set Alert body
                appDelegate.dailyNotificationMonday.alertBody = textField.text;
                //Set time zone to default
                appDelegate.dailyNotificationMonday.timeZone = [NSTimeZone defaultTimeZone];
                //Repeat the notification everyday (fires at same time
                //as initial notification)
                appDelegate.dailyNotificationMonday.repeatInterval = NSWeekCalendarUnit;

                // schedule notification
                UIApplication *app = [UIApplication sharedApplication];
                [app scheduleLocalNotification:appDelegate.dailyNotificationMonday];

                NSLog(@"Monday Fire Date: %@", appDelegate.dailyNotificationMonday.fireDate);
            }
        }
        else {
           [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationMonday]; 
        }

        if ([[defaults objectForKey:@"dailyReminderTuesday"] isEqualToString:@"1"])
        {
            //Set up the local notification
            appDelegate.dailyNotificationTuesday = [[UILocalNotification alloc] init];
            if(appDelegate.dailyNotificationTuesday){
                //Set fire date to alert time
                appDelegate.dailyNotificationTuesday.fireDate = tuesdayFireTime;
                //Set Alert body
                appDelegate.dailyNotificationTuesday.alertBody = textField.text;
                //Set time zone to default
                appDelegate.dailyNotificationTuesday.timeZone = [NSTimeZone defaultTimeZone];
                //Repeat the notification everyday (fires at same time
                //as initial notification)
                appDelegate.dailyNotificationTuesday.repeatInterval = NSWeekCalendarUnit;

                // schedule notification
                UIApplication *app = [UIApplication sharedApplication];
                [app scheduleLocalNotification:appDelegate.dailyNotificationTuesday];

                NSLog(@"Tuesday Fire Date: %@", appDelegate.dailyNotificationTuesday.fireDate);
            }
        }
        else {
            [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationTuesday]; 
        }

        if ([[defaults objectForKey:@"dailyReminderWednesday"] isEqualToString:@"1"])
        {
            //Set up the local notification
            appDelegate.dailyNotificationWednesday = [[UILocalNotification alloc] init];
            if(appDelegate.dailyNotificationWednesday){
                //Set fire date to alert time
                appDelegate.dailyNotificationWednesday.fireDate = wednesdayFireTime;
                //Set Alert body
                appDelegate.dailyNotificationWednesday.alertBody = textField.text;
                //Set time zone to default
                appDelegate.dailyNotificationWednesday.timeZone = [NSTimeZone defaultTimeZone];
                //Repeat the notification everyday (fires at same time
                //as initial notification)
                appDelegate.dailyNotificationWednesday.repeatInterval = NSWeekCalendarUnit;

                // schedule notification
                UIApplication *app = [UIApplication sharedApplication];
                [app scheduleLocalNotification:appDelegate.dailyNotificationWednesday];

                NSLog(@"Wednesday Fire Date: %@", appDelegate.dailyNotificationWednesday.fireDate);
            }
        }
        else {
            [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationWednesday]; 
        }

        if ([[defaults objectForKey:@"dailyReminderThursday"] isEqualToString:@"1"])
        {
            //Set up the local notification
            appDelegate.dailyNotificationThursday = [[UILocalNotification alloc] init];
            if(appDelegate.dailyNotificationThursday){
                //Set fire date to alert time
                appDelegate.dailyNotificationThursday.fireDate = thursdayFireTime;
                //Set Alert body
                appDelegate.dailyNotificationThursday.alertBody = textField.text;
                //Set time zone to default
                appDelegate.dailyNotificationThursday.timeZone = [NSTimeZone defaultTimeZone];
                //Repeat the notification everyday (fires at same time
                //as initial notification)
                appDelegate.dailyNotificationThursday.repeatInterval = NSWeekCalendarUnit;

                // schedule notification
                UIApplication *app = [UIApplication sharedApplication];
                [app scheduleLocalNotification:appDelegate.dailyNotificationThursday];

                NSLog(@"Thursday Fire Date: %@", appDelegate.dailyNotificationThursday.fireDate);
            }
        }
        else {
            [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationThursday]; 
        }

        if ([[defaults objectForKey:@"dailyReminderFriday"] isEqualToString:@"1"])
        {
            //Set up the local notification
            appDelegate.dailyNotificationFriday = [[UILocalNotification alloc] init];
            if(appDelegate.dailyNotificationFriday){
                //Set fire date to alert time
                appDelegate.dailyNotificationFriday.fireDate = fridayFireTime;
                //Set Alert body
                appDelegate.dailyNotificationFriday.alertBody = textField.text;
                //Set time zone to default
                appDelegate.dailyNotificationFriday.timeZone = [NSTimeZone defaultTimeZone];
                //Repeat the notification everyday (fires at same time
                //as initial notification)
                appDelegate.dailyNotificationFriday.repeatInterval = NSWeekCalendarUnit;

                // schedule notification
                UIApplication *app = [UIApplication sharedApplication];
                [app scheduleLocalNotification:appDelegate.dailyNotificationFriday];

                NSLog(@"Friday Fire Date: %@", appDelegate.dailyNotificationFriday.fireDate);
            }
        }
        else {
            [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationFriday]; 
        }

        if ([[defaults objectForKey:@"dailyReminderSaturday"] isEqualToString:@"1"])
        {
            //Set up the local notification
            appDelegate.dailyNotificationSaturday = [[UILocalNotification alloc] init];
            if(appDelegate.dailyNotificationSaturday){
                //Set fire date to alert time
                appDelegate.dailyNotificationSaturday.fireDate = saturdayFireTime;
                //Set Alert body
                appDelegate.dailyNotificationSaturday.alertBody = textField.text;
                //Set time zone to default
                appDelegate.dailyNotificationSaturday.timeZone = [NSTimeZone defaultTimeZone];
                //Repeat the notification everyday (fires at same time
                //as initial notification)
                appDelegate.dailyNotificationSaturday.repeatInterval = NSWeekCalendarUnit;

                // schedule notification
                UIApplication *app = [UIApplication sharedApplication];
                [app scheduleLocalNotification:appDelegate.dailyNotificationSaturday];

                NSLog(@"Saturday Fire Date: %@", appDelegate.dailyNotificationSaturday.fireDate);
            }
        }
        else {
            [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationSaturday]; 
        }

        if ([[defaults objectForKey:@"dailyReminderSunday"] isEqualToString:@"1"])
        {
            //Set up the local notification
            appDelegate.dailyNotificationSunday = [[UILocalNotification alloc] init];
            if(appDelegate.dailyNotificationSunday){
                //Set fire date to alert time
                appDelegate.dailyNotificationSunday.fireDate = sundayFireTime;
                //Set Alert body
                appDelegate.dailyNotificationSunday.alertBody = textField.text;
                //Set time zone to default
                appDelegate.dailyNotificationSunday.timeZone = [NSTimeZone defaultTimeZone];
                //Repeat the notification everyday (fires at same time
                //as initial notification)
                appDelegate.dailyNotificationSunday.repeatInterval = NSWeekCalendarUnit;

                // schedule notification
                UIApplication *app = [UIApplication sharedApplication];
                [app scheduleLocalNotification:appDelegate.dailyNotificationSunday];

                NSLog(@"Sunday Fire Date: %@", appDelegate.dailyNotificationSunday.fireDate);
            }
        }
        else {
            [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationSunday]; 
        }


    }
    else {
        //Remove all daily notifications
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationMonday];
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationTuesday];
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationWednesday];
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationThursday];
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationFriday];
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationSaturday];
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationSunday];
    }

I also have this piece of code in my AppDelegate:

//Initialze daily notifications
        dailyNotificationMonday = [[UILocalNotification alloc] init];
        dailyNotificationTuesday = [[UILocalNotification alloc] init];
        dailyNotificationWednesday = [[UILocalNotification alloc] init];
        dailyNotificationThursday = [[UILocalNotification alloc] init];
        dailyNotificationFriday = [[UILocalNotification alloc] init];
        dailyNotificationSaturday = [[UILocalNotification alloc] init];
        dailyNotificationSunday = [[UILocalNotification alloc] init];

        //Initialize submition notifications
        submitNotification = [[UILocalNotification alloc] init];
        badgerNotification = [[UILocalNotification alloc] init];

        //Initialize Automatic backup notification
        automaticBackupNotification  = [[UILocalNotification alloc] init];

Which is only called once when the application is first launched.

I’m not used to using local notifications at all, but I don’t understand whats going on here, it seems to me like I’m trying to cancel a notification that doesn’t exist?

Any advice would be much appreciated.

Thanks,

Tysin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:44:49+00:00Added an answer on June 8, 2026 at 8:44 pm

    It looks like appDelegate.dailyNotificationMonday is nil. This doesn’t seem to be a valid value to pass to -cancelLocalNotification:.

    Have you tried:

    if (appDelegate.dailyNotificationMonday)
        [[UIApplication sharedApplication] cancelLocalNotification:appDelegate.dailyNotificationMonday];
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My java Fx webview throws JS exception for following code. Can anyone explain me
The following code works fine on Linux but throws an exception on OS X
I was suprised when found that the following code throws exception at runtime: class
The below piece of code that throws the following exception.. Error Message: Object reference
I am getting the following index out of bounds error: *** Terminating app due
Why does the following code throw an exception when getting to the second scanf_s
I was expecting the following code to throw an exception when I goto write
Argument exception error is thrown at the following code. It's a simple code but
I have following code using hibernate to throw a custom exception on error and
Consider the following code where LockDevice() could possibly fail and throw an exception on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.