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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:17:45+00:00 2026-05-19T03:17:45+00:00

sorry If am I being too picky on this one but I am learning

  • 0

sorry If am I being too picky on this one but I am learning iOS programming now and I’ve seem some people who declare the IBOutlet like this:

IBOutlet attached to property

#import <UIKit/UIKit.h>
#import "CustomCell.h"

@interface CustomTableViewController : UITableViewController {
  CustomCell *customCell;
}
@property (nonatomic, retain) IBOutlet CustomCell *customCell;
@end

And some declaring like this:

IBOutlet attached to the declaration inside the interface

#import <UIKit/UIKit.h>
#import "CustomCell.h"

@interface CustomTableViewController : UITableViewController {
  IBOutlet CustomCell *customCell;
}
@property (nonatomic, retain) CustomCell *customCell;
@end

which one is the proper way to declare it? Are any differences between them?
If someone know to explain why do they put it on different places it would be awesome to learn.

Thanks a lot 🙂

  • 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-19T03:17:46+00:00Added an answer on May 19, 2026 at 3:17 am

    Both of those are still “inside the interface” so your title it a bit confusing but I see what you are asking.

    In many cases the result of either approach will be the same but they are different. An IBOutlet property will call the property’s setter method which gives you an opportunity to override that setter if setting that property should have some side effect.

    I prefer to use outlets on properties because I think it makes the memory management of the objects loaded from the nib much clearer. Take a look at memory management of nib objects and I think you will see what I mean.

    Objects in the nib file are created with a retain count of 1 and then autoreleased. As it rebuilds the object hierarchy, UIKit reestablishes connections between the objects using setValue:forKey:, which uses the available setter method or retains the object by default if no setter method is available. This means that (assuming you follow the pattern shown in “Outlets”) any object for which you have an outlet remains valid. If there are any top-level objects you do not store in outlets, however, you must retain either the array returned by the loadNibNamed:owner:options: method or the objects inside the array to prevent those objects from being released prematurely.

    IBOutlet ivars will call setters for those ivars if they exists and directly retain the object loaded from the nib if no setter is found.

    Advertising the property as the IBOutlet at least makes it clear that the property’s setter will always be used and follow whatever memory management rule has been set for that property.

    Finally I argue that IBOutlets are part of the public interface of a class and it is therefore better to expose methods (via a property) for working with them eager than using -setValue:forKey: to manipulate the backing ivars which should be an implementation detail.

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

Sidebar

Related Questions

I'm sorry to have to bring up this as well. But it doesn't seem
First time poster so sorry if this is too long, but I've hit a
Sorry if this is too noobish a question. Thank you for being patient... I'm
Sorry for being the 100000th person to ask the same question. But I guess
guys sorry for being so noob but im still starting yet with my php,
Ok so sorry for being, I guess, a bit off topic but still I
Sorry, I'm sure this is simple but I'm tired and can't figure it out.
really sorry about being totally thick today but I have forgotten how to do
this is my first stack overflow, and it's a complex one. Sorry. My task
Sorry in advance if I have some of this wrong. I may edit to

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.