Note that there are some explanatory texts on larger screens.

plurals
  1. POUIViewController Retaining in ARC
    primarykey
    data
    text
    <p>I have a subclass of UIViewController -> MyPopUpViewController</p> <pre><code>@protocol MyPopUpViewController Delegate; @interface MyPopUpViewController : UIViewController { } @property (nonatomic, strong) id &lt;MyPopUpViewControllerDelegate&gt; delegate; -(IBAction) buttonPressed:(id)sender; @end @protocol MyPopUpViewControllerDelegate -(void) popupButtonPressed: (MyPopUpViewController*)controller; @end </code></pre> <p>I cannot have this MyPopUpViewController as an instance variable because this comes externally, and there could be many and multiple of these popups can be up. So far I tried this, and it crashes on the delegate call due to not being retained:</p> <p>MyMainViewController:</p> <pre><code>-(void)externalNotificationReceived: (NSString*) sentMessage { MyPopUpViewController *popupView = [[MyPopUpViewController alloc] init]; popupView.delegate = self; [self.view addSubview:popupView.view]; [popupView setInfo :sentMessage :@"View" :@"Okay"]; popupView.view.frame = CGRectMake(0, -568, 320, 568); popupView.view.center = self.view.center; } -(void)popupButtonPressed:(MyPopUpViewController *)controller :(int)sentButtonNumber { NSLog(@"Popup Delegate Called"); [controller.view removeFromSuperview]; controller.delegate = nil; controller = nil; } </code></pre> <p>Once the popup comes up, and when the ok button is tapped, it crashes and never gets to that NSLog. How can I change </p> <p>MyPopUpViewController *popupView = [[MyPopUpViewController alloc] init];</p> <p>..so it would retain without making it an instance variable?</p> <p>Thanks in advance.</p>
    singulars
    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