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

  • Home
  • SEARCH
  • 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 6335305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:49:50+00:00 2026-05-24T18:49:50+00:00

Is it better to only create an instance variable for a control or an

  • 0

Is it better to only create an instance variable for a control or an instance variable with a property in objective c/xcode?

If you are to create a property is it best to make it atomic or nonatomic (for a control).

For example, what is the best practice for doing the following:

@interface blah
{
  UILabel *label;
}

@property (nonatomic, retain) IBOutlet UILabel *label;

OR

@interface blah
{
  IBOutlet UILabel *label;
}

OR

@interface blah
{    
  UILabel *label;
}

@property (retain) IBOutlet UILabel *label;

Then when I dealloc is it best to do:

[self.label release]

or
[label release]

EDIT:

So to summarize…

  1. When referencing controls in you code, you should use instance variables
  2. In dealloc, you can release the controls by [iVal release]\
  • 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-24T18:49:51+00:00Added an answer on May 24, 2026 at 6:49 pm

    I wouldn’t create a property for label since it doesn’t need to be accessed outside of UIViewController, hence I’d use second case. The thing regarding atomicity – logic dictates that since UI should be updated from main thread only, UILabel should be accessed only in main thread too. So it virtually doesn’t matter if you declare your property nonatomic or atomic, you’d access and alter that UILabel var only from main thread.

    Performance-wise, nonatomic properties are faster too since access does not need to acquire lock.

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

Sidebar

Related Questions

Are there good reasons why it's a better practice to have only one return
I wish Subversion had a better way of moving tags. The only way that
Which of the following is better? a instanceof B or B.class.isAssignableFrom(a.getClass()) The only difference
Better yet, how can I make My Computer always open in Explorer as well?
I have a requirement to have a only a single instance of a class
If I create a ViewController with a map view and this is the only
Can you please tell me how is best to do? How can I create
Or better said: When to use array as a field data type in a
Even better would be if autoResize in latest branch would work as intended, but
For better description, +-----------------------+ | Desktop (screen) | | | | | | +----------+

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.