EXC_BAD_ACCESS due to PostNotification
- by Sagar Mane
Hello All,
I am facing one issue regarding one module let me clear the flow for the same.
I have one customized UITableviewCell.
When I am getting some new information I am posting one notification
[[NSNotificationCenter defaultCenter] postNotificationName:KGotSomething object:nil userInfo:message];
In view where I am maintaining the table I am initiating a customized cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell= [[CustomCell alloc] initWithFrame: reuseIdentifier:identifier document:doc];
return cell;
}
now in customcell.mm
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(GotSomething:)
name:KGotSomething
object:nil];
}
and in dealloc
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:KGotSomething
object:nil];
}
Now my app crashes due to this notification and dealloc is never get called.
Can you guys help me, how to get this working or anything I m doing wrong over here...
Thanks,
Sagar