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 8205427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:14:10+00:00 2026-06-07T08:14:10+00:00

I want to create a new UILocalNotification every time I enter a certain method.

  • 0

I want to create a new UILocalNotification every time I enter a certain method. I would assume this would have to be done by reading from an array or something along this line but I cannot figure it out. How do I do such a thing dynamically without hardcoding something like the following:

-(void) createNotification
 {
 UILocalNotification *notification1;
 }

Now I would like to be able to create notification2, notification3, etc etc each time I enter createNotification. For the specific reason that then I can cancel the appropriate notification without cancelling them all.

The following is what I have attempted, perhaps Im way off… maybe not. Either way if someone could provide some input, would be appreciated. Thanks!

-(void) AddNewNotification
{

UILocalNotification *newNotification = [[UILocalNotification alloc] init];
//[notificationArray addObject:newNotification withKey:@"notificationN"];
notificationArray= [[NSMutableArray alloc] init];

[notificationArray addObject:[[NSMutableDictionary alloc]
                   initWithObjectsAndKeys:newNotification,@"theNotification",nil]];

  }
  • 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-07T08:14:11+00:00Added an answer on June 7, 2026 at 8:14 am

    You are almost there: using an array is certainly the right thing to do! The only problem is that you keep creating a new instance of the array every time you go through your AddNewNotification method. You should make notificationArray an instance variable, and move its initialization code notificationArray= [[NSMutableArray alloc] init]; to the designated initializer of the class where notificationArray is declared.

    If you would like to give each notification that you insert an individual key by which you can find it later, use NSMutableDictionary instead of NSMutableArray. Re-write the AddNewNotification method as follows:

    -(void) addNewNotificationWithKey:(NSString*)key {
        UILocalNotification *newNotification = [[UILocalNotification alloc] init];
        [notificationDict setObject:[[NSMutableDictionary alloc]
                   initWithObjectsAndKeys:newNotification,@"theNotification",nil]
            forKey:key];
    
    }
    

    When you call the addNewNotificationWithKey: method, you’d be able to provide a key for the newly added notification, for example

    [self addNewNotificationWithKey:@"notification1"];
    [self addNewNotificationWithKey:@"notification2"];
    

    and so on.

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

Sidebar

Related Questions

I have the following state machine and I want this: create a new order
i want to create new file iam using this code try { File file
I want to create new instance of my custom PSObject. I have a Button
I have a multidimensional array and I want to create new variables based on
I have following string. $option = '+'; $value = '100'; I want create new
I want to create two sites on RubyOnRails and would like to simplify this
In my application i have 'Contacts' & 'Invitations' When i want to create new
I have two database named: olddatabase and newdatabase. I want to create a new
I want to create new WCF service and client. The 2 parties will communicate
I want to create new creative and check its audit status in facebook ads

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.