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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:52:53+00:00 2026-06-14T22:52:53+00:00

The following code was working prior to upgrading to iOS 6. It works in

  • 0

The following code was working prior to upgrading to iOS 6. It works in the 5.1 iPhone simulator as well, but fails with 6.0 simulator and device.

Trying to setObject:forKey in a loop to an NSMutableDictionary. Have tried adding in the loop (as the following code shows) and also tried by initializing with arrays for objects and keys which results in the same failure. Another strange bit of information is that sometimes it works but fails most of the time. The object being added is a UILocalNotification and the key is an object that represents a WeekDay (more than a simple string). The output of running is shown below. The UILocalNotifications and keys are clearly not NULL but the added pair in the MutableDictionary has NULL for some of the objects most of the time. Mostly it’s the last added day (key) whose object is null. I’m completely at a loss as to how this breaking, thanks in advance for any help!

copy method for WeekDay (NSCopying Protocol):

- (id)copyWithZone:(NSZone *)zone
{
    WeekDay * copy = [[WeekDay alloc] initWithDay:self.day];
    return copy;
}

code snippet using setObject:forKey:

NSMutableDictionary * newAlarmsDictionary = [[NSMutableDictionary alloc] init];
NSArray * theDayKeys = [[_daysEnabledDict allKeys] sortedArrayUsingSelector:@selector(compare:)];

NSMutableArray * tempNotifyArray = [[NSMutableArray alloc] init];
UILocalNotification * theAlarm = nil;
WeekDay * theWeekDay = nil;

for (int i=0; i < [theDayKeys count]; i++) {

    if ([[_daysEnabledDict objectForKey:[theDayKeys objectAtIndex:i]] boolValue] == TRUE) {

        theWeekDay = [theDayKeys objectAtIndex:i];

        NSDate * now = [NSDate date];

... deleted lines setting up fire date for UILocalNotification, not significant to problem ...

        theAlarm = [[UILocalNotification alloc] init];
        theAlarm.fireDate = itemDate;
        theAlarm.repeatInterval = NSWeekCalendarUnit;
        theAlarm.timeZone = [NSTimeZone localTimeZone];
        theAlarm.soundName = UILocalNotificationDefaultSoundName;
        theAlarm.applicationIconBadgeNumber = 0;

        [newAlarmsDictionary setObject:theAlarm forKey:theWeekDay];
        [tempNotifyArray addObject:theAlarm];
        [theAlarm release];
        }
    }
}
NSLog(@"--Debug: tempNotifyArray---- %@ -------------", tempNotifyArray);
NSLog(@"--Debug: newAlarmsDictionary ====== %@ =============", newAlarmsDictionary);

Here is the output of the two NSlog statements at the end of the code snippet. This particular run adds 4 notifications, for days wed thru sat. The ‘alarms’ put into the tempNotifyArray are valid but when added to the dictionary (one in this case) is null.

2012-11-26 11:07:01.087 MedTrack[9728:11303] --Debug: tempNotifyArray---- (

"<UIConcreteLocalNotification: 0x7277940>{fire date = Wednesday, November 28, 2012, 11:06:00 AM Eastern Standard Time, time zone = America/Toronto (EST) offset -18000, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Wednesday, November 28, 2012, 11:06:00 AM Eastern Standard Time, user info = {\n    Temp = Fred;\n}}",


"<UIConcreteLocalNotification: 0x8883280>{fire date = Thursday, November 29, 2012, 11:06:00 AM Eastern Standard Time, time zone = America/Toronto (EST) offset -18000, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Thursday, November 29, 2012, 11:06:00 AM Eastern Standard Time, user info = {\n    Temp = Fred;\n}}",


"<UIConcreteLocalNotification: 0x75c6590>{fire date = Friday, November 30, 2012, 11:06:00 AM Eastern Standard Time, time zone = America/Toronto (EST) offset -18000, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Friday, November 30, 2012, 11:06:00 AM Eastern Standard Time, user info = {\n    Temp = Fred;\n}}",


"<UIConcreteLocalNotification: 0x75c83e0>{fire date = Saturday, December 1, 2012, 11:06:00 AM Eastern Standard Time, time zone = America/Toronto (EST) offset -18000, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Saturday, December 1, 2012, 11:06:00 AM Eastern Standard Time, user info = {\n    Temp = Fred;\n}}"

) ————-

2012-11-26 11:07:01.097 MedTrack[9728:11303] --Debug: newAlarmsDictionary ====== {


"[WeekDay] 6 (Sat)" = (null);


"[WeekDay] 3 (Wed)" = "<UIConcreteLocalNotification: 0x7277940>{fire date = Wednesday, November 28, 2012, 11:06:00 AM Eastern Standard Time, time zone = America/Toronto (EST) offset -18000, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Wednesday, November 28, 2012, 11:06:00 AM Eastern Standard Time, user info = {\n    Temp = Fred;\n}}";


"[WeekDay] 4 (Thu)" = "<UIConcreteLocalNotification: 0x8883280>{fire date = Thursday, November 29, 2012, 11:06:00 AM Eastern Standard Time, time zone = America/Toronto (EST) offset -18000, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Thursday, November 29, 2012, 11:06:00 AM Eastern Standard Time, user info = {\n    Temp = Fred;\n}}";


"[WeekDay] 5 (Fri)" = "<UIConcreteLocalNotification: 0x75c6590>{fire date = Friday, November 30, 2012, 11:06:00 AM Eastern Standard Time, time zone = America/Toronto (EST) offset -18000, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Friday, November 30, 2012, 11:06:00 AM Eastern Standard Time, user info = {\n    Temp = Fred;\n}}";    
  • 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-14T22:52:54+00:00Added an answer on June 14, 2026 at 10:52 pm

    The issue here is that you implement -copyWithZone:, but you fail to implement -isEqual:. Without knowing the full structure of your object, I cannot answer how that should be implemented, but here’s a good basis:

    - (BOOL)isEqual:(id)otherObject;
    {
        if ([otherObject isKindOfClass:[self class]]) {
            WeekDay *otherWeekDay= (WeekDay *)otherObject;
            if (self.day != [otherWeekDay day]) return NO;
            if (self.name != [otherWeekDay name]) return NO;
            return YES;
        }
        return NO;
    }
    
    - (NSUInteger) hash;
    {
        return self.day ^ [self.name hash];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code working fine, but I'm unable to add a zoom
I have following code working nicely on all browsers but IE 7... <script type=text/javascript>
I have the following code working fine but the problem is that it always
I have been trying to get the following code working. It's a progress bar
I have following code working on a development environment (SQLite) but generating an error
Basically I have the following code working, but i can not find a way
I'm trying to get the following code working: string url = String.Format(@SOMEURL); string user
In YUI I have following code working for mouse wheel. How do I make
We have the following code working for a complex rails form with checkboxes. I'm
Right now I have the following code working: @UiHandler(usernameTextBox) void onUsernameTextBoxKeyPress(KeyPressEvent event) { keyPress(event);

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.