EXC_BAD_ACCESS due to PostNotification

Posted by Sagar Mane on Stack Overflow See other posts from Stack Overflow or by Sagar Mane
Published on 2010-06-15T09:07:44Z Indexed on 2010/06/15 9:12 UTC
Read the original article Hit count: 535

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad