Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't see any problem with that. Pre-ARC, I've always made my IBOutlets <code>assign</code>, as they're already retained by their superviews. If you make them <code>weak</code>, you shouldn't have to nil them out in viewDidUnload, as you point out. </p> <p>One caveat: You can support iOS 4.x in an ARC project, but if you do, you can't use <code>weak</code>, so you'd have to make them <code>assign</code>, in which case you'd still want to nil the reference in <code>viewDidUnload</code> to avoid a dangling pointer. Here's an example of a dangling pointer bug I've experienced:</p> <p>A UIViewController has a UITextField for zip code. It uses CLLocationManager to reverse geocode the user's location and set the zip code. Here's the delegate callback:</p> <pre><code>-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { Class geocoderClass = NSClassFromString(@"CLGeocoder"); if (geocoderClass &amp;&amp; IsEmpty(self.zip.text)) { id geocoder = [[geocoderClass alloc] init]; [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) { if (self.zip &amp;&amp; IsEmpty(self.zip.text)) { self.zip.text = [[placemarks objectAtIndex:0] postalCode]; } }]; } [self.locationManager stopUpdatingLocation]; } </code></pre> <p>I found that if I dismissed this view at the right time and didn't nil self.zip in <code>viewDidUnload</code>, the delegate callback could throw a bad access exception on self.zip.text.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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