Note that there are some explanatory texts on larger screens.

plurals
  1. POEXC_BAD_ACCESS on selector in objective C
    primarykey
    data
    text
    <p>I've got a UIBarButtonItem category where I build UIBarButtonItems with custom UIButtons, since I've found UIButtons easier to customize then UIBarButtonItems.</p> <p>Now, I'd like to continue to use the BarButtonItem's target and action properties instead of using those in the button so that the BarButtonItem can continue to be customized externally without anyone having to know the implementation details (i.e., that it is using a button internally).</p> <p>Now, in order to do that, I'm written up this code in my category:</p> <pre><code>+ (UIBarButtonItem *)backBarButtonItemWithColor:(UIColor *)color { UIImage *closeIcon = [MyImageUtility navBarBackArrow]; if (color) closeIcon = [closeIcon imageWithColorOverlay:color]; UIButton *close = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, closeIcon.size.width+10.0f, closeIcon.size.height+10.0f)]; UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:close]; [close setImage:closeIcon forState:UIControlStateNormal]; [close addTarget:item action:@selector(SD_executeBarButtonItemAction) forControlEvents:UIControlEventTouchUpInside]; return item; } - (void)SD_executeBarButtonItemAction { [self.target performSelector:self.action]; } </code></pre> <p>Whenever the SD_executeBarButtonItemAction is called, I get a exc_bad_access on the selector, though I am not sure why. Any ideas? Is there a way around this?</p> <p>Thanks!</p> <p>EDIT: </p> <p>here is the code being called by that selector that is crashing:</p> <pre><code>void (^transition)(void) = ^(void) { [self.rightContainer setFrame:[self offscreenContainerFrame]]; [self.centerContainer setAlpha:1.0f]; //TODO: this is unreliable in iOS6 -- we should add a view to the top of it to darken [self.centerContainer setTransform:CGAffineTransformIdentity]; }; [self notifyWillShowPrimaryViewController]; [self performBlock:transition animated:YES completion:^(BOOL finished) { [self notifyDidShowPrimaryViewController]; [self setForegroundController:self.primaryNavigationController]; if (block != NULL) block(finished); }]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload