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 566427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:58:34+00:00 2026-05-13T12:58:34+00:00

While coding always the same questions concerning retain counts of IBOutlets came along: Retain

  • 0

While coding always the same questions concerning retain counts of IBOutlets came along: Retain count after unarchiving an object from NIB? When to use @property’s for an IBOutlet? Retain or assign while setting? Differences between Mac and iPhone?

So I read The Nib Object Life Cycle from Apple’s documentation. Some test apps on Mac and iPhone gave me some strange results. Nevertheless I wrote down a few rules how to handle this issue to stay happy while coding but now wanted to verify with the community and listen to your opinions and experiences:

  1. Always create an IBOutlet for top-level objects. For non-top-level objects if necessary (access needed).
  2. Always provide a property as follows for IBOutlets (and release them where necessary!):
    • Top-level objects on Mac:
      • @property (nonatomic, assign) IBOutlet SomeObject *someObject;
      • @synthesize someObject;
      • [self.someObject release];
    • Non-top-level objects on Mac (no release):
      • @property (nonatomic, assign) IBOutlet NSWindow *window;
      • @synthesize someObject;
    • Top-level objects on iPhone (must retain):
      • @property (nonatomic, retain) IBOutlet SomeObject *someObject;
      • @synthesize someObject;
      • [self.someObject release];
    • Non-top-level objects on iPhone (should retain):
      • @property (nonatomic, retain) IBOutlet UIWindow *window;
      • @synthesize window;
      • [self.window release];

Side notes:

  • On Mac and iPhone outlet connections are made with a setter if available.
  • Top-level objects: “have […] no owning object”
  • Non-top-level objects: “any objects that have a parent or owning object, such as views nested inside view hierarchies.”

So the question would be: is this correct and good practice?

I hope you can approve or correct it.

  • 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-13T12:58:34+00:00Added an answer on May 13, 2026 at 12:58 pm

    Always have your nibs’ File’s Owner be a subclass of NSWindowController or NSViewController (on Mac OS X) or UIViewController (on iPhone), and use @property (retain) IBOutlet for all of its outlets, doing appropriate releases in your controller subclass -dealloc method.

    This pattern will work fine on both Mac OS X and iPhone OS, because NSWindowController and NSViewController on Mac OS X take implicit ownership of top-level objects for you (and relinquish that in their own -dealloc methods), and iPhone OS doesn’t take any implicit ownership of top-level objects for you during nib loading.

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

Sidebar

Related Questions

Similar Questions While coding, how many columns do you format for? What is a
While coding with sqlite everytime i always had the exact number of parameters and
I have always had an interest in coding, and a while back a started
While coding python I'm using only 2 spaces to indent, sure PEP-8 really recommend
Is there anything I can do while coding in Asp.net to make my website
What are the naming conventions that you use while coding?
I've been drooling over Django all day while coding up an internal website in
I Want to know which one is preferred while coding to use Static Methods
I used many different browsers while I was coding for a new site (Firefox,
Should we only use Web-Safe Colors while in design/coding/development for website/apps?

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.