Question

For some reason I'm getting an error when tapping a button that is hooked up to an IBAction. In my homeViewController a user performs an action, adding a new viewController to the navigationController, and within this view controller's view is a smaller view containing the button. I reveiwed my code, and looked through the inspector to see if I missed anything but nothing weird stood out.

Here's my added view controller's .h file:

@property (weak, nonatomic) IBOutlet UIView *popupView;
@property (weak, nonatomic) IBOutlet UIImageView *blurredImageView;
@property (weak, nonatomic) UIImage *blurredImage;

- (void)presentEventEditViewControllerWithEventStore:(EKEventStore*)eventStore;
- (IBAction)addEvent:(id)sender;;
- (IBAction)cancelEvent:(id)sender;

When I tap a button without linking the IBActions to either of them, no error. As soon as I link them, the app crashes and displays the following error:

enter image description here

P.S. I also received the following in a prior error (Before unlinking and relinking):

-[OS_xpc_connection cancelEvent:]:

UPDATE:

I load the bannerViewController the following way:

BannerPopUpViewController *BPV = [[BannerPopUpViewController alloc] initWithNibName:@"BannerPopUpViewController" bundle:nil];
    BPV.blurredImage = [self screenshot];
    [self.view.window addSubview:BPV.view];

Here is the first error I was referring to, courtesy of crashlytics:

enter image description here

But the one I keep getting, since I unlinked the action and relinked is the following:

enter image description here

Was it helpful?

Solution

When you do:

[self.view.window addSubview:BPV.view];

The view is retained by its superview (the window in this case), but nothing is retaining the BPV view controller. Something needs to or it will get deallocated and then whenever any button is pressed it will result in a call to a destroyed object (turn on zombies to verify).

Retain BVP somewhere by saving it in a strong property of adding it as a chile view controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top