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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:12:39+00:00 2026-06-15T08:12:39+00:00

Consider a situation where you have an object in a storyboard file linked up

  • 0

Consider a situation where you have an object in a storyboard file linked up to an IBOutlet, such as the following.

@property (nonatomic, strong) IBOutlet UIImageView *imageView;

Left to its own devices, the ViewController will happily load and display the correct image inside the correct frame, etc, as determined in Interface Builder.
However, if the following code is added to the View Controller’s viewDidLoad method, an (apparently) identical outcome is achieved.

- (void)viewDidLoad {
    _imageView = [[UIImageView alloc] init];
    //...
}

Does this mean the programmatic alloc-initing of IBOutlets is completely optional? Or is the addition of this line achieving a slightly different outcome?

I’m asking because I have always added the alloc-init in the implementation, then in my latest project I forgot about it, and to my surprise, it still worked exactly as intended.

  • 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-06-15T08:12:39+00:00Added an answer on June 15, 2026 at 8:12 am

    A storyboard or xib file is a serialisation of the objects contained within. When the storyboard is loaded, all of the objects are instantiated (using initWithCoder:, since we are deserialising them). This does the same job as allo/init, with the addition of setting all of the properties of the object that are defined in the xib.

    The xib contains enough information about your image view to fully create it. If you then alloc/init a new image view and assign it to the variable that was used for the outlet, you are just replacing the object that was created from the storyboard, which is pretty pointless, since your outlet now points to nothing on the screen.

    In summary – alloc/init ing every outlet isn’t optional, it’s wrong.

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

Sidebar

Related Questions

Consider the following situation: We have two Localizable.string files, one in en.lproj and one
Consider the following situation: I have two android projects named P1 and P2 which
Consider following situation: Object > MyClass > MyClassA, MyClassB If I want something in
Consider the following common situation: You have some MainView in your Cocoa application, loaded
Consider the following situation. We have a database which stores writers and books in
So, please consider the following situation I have a super class of type Shapes
Consider the following situation where I have a list of n matrices (this is
Consider the below situation I have a database table as below user_id user_rank ------------------
Consider a situation. I have an in-proc COM server that contains two COM classes.
Consider the following situation Code was added to the trunk at revision x A

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.