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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:06:32+00:00 2026-05-17T18:06:32+00:00

I have a transformable attribute on one of my entities, called reminder. It’s a

  • 0

I have a transformable attribute on one of my entities, called reminder. It’s a UILocalNotification.

Now, since I want to schedule it when it’s added, and cancel it when removed, I would like to override the accessors to handle the scheduling and cancelling in there.

How would that look?

Thanks!

  • 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-05-17T18:06:33+00:00Added an answer on May 17, 2026 at 6:06 pm

    Are you actually persisting the UILocalNotification or are you using it as a transient property?

    I wouldn’t store it, rather UILocalNotification as a userInfo as a property. You can at a key/value pair to that dictionary with information about the owning entity. For instance:

    You create a value for the key notificationID in the userInfo dictionary and set a attribute notificationID on your Core Data entity to the same value. That way, you just have to store an int or NSString in your store (which is preferable to transformable).

    When you want to fetch your UILocalNotification again you can make an accessor on your Entity Class, something like:

    - (void)createNotification
    {
        static NSUInteger kDeadlineWarningPeriod = 3600;
        UILocalNotification *notification = [[UILocalNotification alloc] init];
    
        …
    
        self.notificationID = @"some generated ID";
    
        [notification.userInfo setValue:self.notificationID forKey:@"notificationID"];
    
        [[UIApplication sharedApplication] scheduleLocalNotification:notification];
        [notification release];
    }
    
    - (void)cancelNotification
    {
        // We search for the notification.
        // The entity's ID will be stored in the notification's user info.
    
        [[[UIApplication sharedApplication] scheduledLocalNotifications] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    
        UILocalNotification *notification = (UILocalNotification *)obj;
        NSDictionary *userInfo = notification.userInfo;
    
        NSString *notificationID = [userInfo valueForKey:@"notificationID"];
    
        if ([notificationID isEqualToString:self.notificationID])
        {
            [[UIApplication sharedApplication] cancelLocalNotification:notification];
            *stop = YES;
                        self.notificationID = nil;
        }
         }];
    }
    

    Of course you can make an accessor for your notification in much the same way if you actually need access to the notification object.

    Hope it helps.

    UPDATE

    So since you have a property you call reminder on you Entity (I’m guessing that it is a BOOL) it will look something like this:

    // .h
    
    @property (nonatomic, assign) BOOL reminder;
    
    // .m
    
    - (void)setReminder:(BOOL)reminder {
    
       [self willAccessValueForKey@"reminder"];
       BOOL hasReminder = [[self primitiveValueForKey:@"reminder"] booleanValue];
       [self didAccessValueForKey:@"reminder"];
    
       if (hasReminder && !reminder) {
    
            [self cancelNotification];
       }
       else if (!hasReminder && reminder) {
    
            [self createNotification];
       }
    
       if (reminder != hasReminder)
       {
            [self willChangeValueForKey:@"reminder"];
            [self setPrimitiveValue:[NSNumber numberWithBool:reminder] forKey@"reminder"];
            [self didChangeValueForKey:@"reminder"];
       }
    }
    

    In fact you don’t really have to store the “reminder” attribute at all, you can just check if the notificationID attribute is nil or not. That was the idea from my suggestion before.

    I haven’t checked the code above but I do something similar in two of my projects.

    Remember you can get into trouble if you create more than 64 local notifications, since you are only allowed to make that many per app. So you might want to track how many you have before creating any new ones.

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

Sidebar

Related Questions

I have created an Entity in CoreData that includes a Transformable attribute type implemented
I have only one entity, which has two attributes: an NSString attribute and a
I have a CoreData NSManagedObject subclass, TextNarration, that has an attribute of type NSString,
I have an entity called Task in my Core Data model. The Task entity
I have a Core Data app with a fairly simple data model. I want
I have a Core Data model entity NoteObject that has a transformable type arrayOfTags
Have any one tried to activate fancybox thumbnail gallery using a button or an
Have just started to get into CakePHP since a couple of weeks back. I
I have an image field of type transformable and a typical ImageToDataTransformer class. 99%
I'm storing a photo as a Transformable attribute in my Core Data entity, which

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.