Note that there are some explanatory texts on larger screens.

plurals
  1. POARC and Popovers and delegates
    text
    copied!<p>i am tearing my hair out, I have migrated my old project to arc and I'm getting this error popping up : <em>*</em> Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'</p> <p>I have read through some threads and I'm confused, some say when using delegates use a weak reference but on the other hand when using popovers use a strong property reference, can someone give me an example of how best to use ARC and delegates with a popover that has a button inside that changes the background colour for example?</p> <p>From what I've read I keep hearing use an instance variable in my view controller, here it is in my main view controller:</p> <pre><code>@property (nonatomic, strong) UIPopoverController *currentPopover; </code></pre> <p>and the is the method implementation in the main view controller file:</p> <pre><code>- (IBAction)ShowPopTextColor:(id)sender { if (currentPopover == nil) { TimerTextColor *timerTextColor = [[TimerTextColor alloc]init]; timerTextColor.delegate =self; UIPopoverController *pop = [[UIPopoverController alloc]initWithContentViewController:timerTextColor]; [pop setDelegate:self]; [pop setPopoverContentSize:CGSizeMake(320, 240)]; [pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; //[pop release]; } else { [currentPopover dismissPopoverAnimated:YES]; currentPopover = nil; } } </code></pre> <p>here is my popup content header:</p> <pre><code>@protocol colorChooserDelegate -(void) colorSelected:(UIColor*)thecolor; @end @interface TimerTextColor : UIViewController{ id&lt;colorChooserDelegate&gt; delegate; IBOutlet UIButton *colorView; } - (IBAction)buttonTapped:(id) sender; @property (nonatomic,strong) id&lt;colorChooserDelegate&gt;delegate; @property (nonatomic,strong) UIButton *colorView; @end </code></pre> <p>What am i doing wrong?</p>
 

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