Hi
I am using notifications to pass data from a detail view controller to the rootviewcontroller in my app. The methods work fine until there is a memory warning.
The notification is handled twice after any memory warnings.
I pass data back to the rootviewcontroller when the user selects a row in the DetailViewController. The didSelectRowAtIndexPath method is called just once but the notification observer is called twice!
Should I be removing the notification in didReceiveMemoryWarning? Or is there some other problem with the code?
Posting the relevant code
RootViewController's viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rowSelected:) name:@"SelectionNotification" object:nil];
DetailViewController's didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init] autorelease];
[dictionary setObject:selectedRow forKey:@"row"];
[[NSNotificationCenter defaultCenter] postNotificationName:kSelectionNotificationName object:self userInfo:dictionary];
[[self navigationController] popToRootViewControllerAnimated:YES];
}
Thanks for any help.