Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 882131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:22:45+00:00 2026-05-15T12:22:45+00:00

I keep running into situations with UIViewControllers containing a large amount of IBOutlets connecting

  • 0

I keep running into situations with UIViewControllers containing a large amount of IBOutlets connecting the controller to its view’s subviews (typically UILabels).

Following “best practices”, i.e. use retain on all UI elements: @property (retain, nonatomic) UILabel *theElement1, @property (retain, nonatomic) UILabel *theElement2, … gives me insane amounts of boiler plate code in dealloc and viewDidUnload for the view controller.

The offending IBOutlets are never used nor set outside the UIViewController (the set-method is only used in viewDidUnload and when the nib is loaded) except automatically when the nib is loaded.

The result from “best practice” is:

  • dealloc littered with [theElement1 release], [theElement2 release] etc.
  • viewDidUnload with [self setTheElement1:nil], [self setTheElement2:nil] etc.

However, since all of those elements are known to be retained by the view anyway, and the view is released by the UIViewController at appropriate times, I see absolutely no reason whatsoever for me to manually manage this.

The reason for this particular “best practice” (as far as I can tell) is to be consistent with your retains. But once you start having a large amount of outlets, you’re more likely to miss handling the some outlet somewhere in either of the two methods, than you’ll have trouble correctly changing outlets to “retain” for those special outlets you really want to retain even after the view is goodbye.

Is there some reason for this “best practice” other than the one I know about or should I feel quite free to break this “rule” in the particular case of subviews to an UIViewController’s view?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:22:46+00:00Added an answer on May 15, 2026 at 12:22 pm

    You should stick to this best practice. It protects you from very bizarre crashes when you access IBOutlets after a memory warning. Yes, you need to manually manage your IBOutlets. Accessorizer does a nice job of automating this code.

    Before ObjC 2.0, we had to write all of our accessors by hand, too (@property and @synthesize are very new additions to the language). Things have gotten a lot nicer. As we move to the 64-bit ABI and garbage collection, things get even simpler (and you should expect these things eventually to make their way to iPhone).

    But for now, follow the memory management rules as laid out in Memory Management of Nib Objects. You trade a really small amount of typing for a huge amount of debugging. (Hmm, looks like they’ve updated this doc again; time to study up myself.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a problem I keep running into: I have a lot of situations where
I keep running into this problem over and over. I have a view with
I keep running into this design problem, and I'm not happy with my solution
I keep running into enq: TX - row lock contention, when I run the
I keep running into this error MemCacheError (Broken pipe): Broken pipe on my Rails
I've been using RhinoMocks lately but I keep running into an issue. If I
I'm trying to work through the problems on projecteuler.net but I keep running into
I keep running into a pretty frustrating error in Xcode after implementing a date
I keep running into this exception when trying to set my property phoneNumber: *
I keep running into slight variations of a problem in Java and it's starting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.