I am getting a EXC_BAD_ACCESS (code=2, address=0x8) error when trying to post a notification.
Occasionally I will see:
-[__NSMallocBlock__ handleMessagesReceived:]: unrecognized selector sent to instance 0x9855cd0
The notification post code looks like this:
NSDictionary *notificationInfo = [NSDictionary dictionaryWithObject:outputArray forKey:@"messages"];
[[NSNotificationCenter defaultCenter] postNotificationName:kMESocialHeatmapMessagesReceivedNotification object:nil userInfo:notificationInfo];
The observer code looks like this (this is the only handler for that notification):
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMessagesReceived:) name:kMESocialHeatmapMessagesReceivedNotification object:nil];
And the handler code:
- (void)handleMessagesReceived:(NSNotification *)notification {...}
I have cleaned the project (CMD-SHIF-K, CMD-ALT-SHIFT-K and removed derived data from the Organizer), restarted both Xcode and my machine, and even re-written the involved code. Same issue, and I just don't see that problem.
Any insight GREATLY appreciated.
Cheers,
Chris
========== UPDATE (cannot answer my own question...) ============
Cheers, Phillip and rang, that pointed me in the right direction.
I do understand that EXC_BAD_ACCESS indicates a dealloc'd object, but in this case that just wasn't possible since the main class of the system was holding onto the object in question (the Heatmap).
The problem turned out to be a race condition between the creation of the Heatmap and the populating of the data model it shares. The populating was happening, occasionally, before the Heatmap was finished being created (both are event-driven).
I ended up re-working the code so that the class holding the Heatmap makes a synchronous call to populate the data after the Heatmap is cleaner.
Thanks for the input, it saved me a headache. :)
Chris