I have a view controller, when it parses with completion, I send a notification, and in the subheading, which is contained in another view controller, is added as a talisman. But, when he tries to execute the post notificaiton method, exec_bad_access happens. what's wrong? Codes:
BrandListByIdViewController.m - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSNumber *bid = self.brands[indexPath.row][@"id"]; [self dismissViewControllerAnimated:YES completion:^{ [[NSNotificationCenter defaultCenter] postNotificationName:@"SelectedBrandId" object:nil]; }]; } SearchNewProduct.h @interface SearchNewProduct : UIView @end SearchNewProduct.m - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didSelectedBrandId::) name:@"SelectedBrandId" object:nil]; } } - (void)didSelectedBrandId:(NSNotification *)notif{ NSLog(@"%s", __PRETTY_FUNCTION__); }
Even I get rid of userInfo, still bad access. I created a similar situation in another new project, it works great.
source share