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

The Archive Base Latest Questions

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

Is it better to create a local object for later use like NSDictionary *dic

  • 0

Is it better to create a local object for later use like

NSDictionary *dic = [NSDictionary Dictionary];

or

NSDictionary * dic = nil;

Is it preference thing or is one better then the other?

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

    it’s not like ‘the one is better’, it’s like ‘the other is bad’.

    If you’re going to assign a new object to it later, initialize it to nil, else (you leak memory by losing the reference to the first object created by error.) – EDIT: no, you’re not leaking memory (either because of the autorelease or the automatic reference counting, but anyway, that’s an extra unneeded method call.) That is bad.

    If it’s a mutable collection, create it before you use it, else it will continue being nil and ignoring essentially all messages sent to it, which is also bad.

    Conclusion: it’s not a matter of preference – you must think logically and choose whichever is suited for the specific purpose you are using it for.

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

Sidebar

Related Questions

I would like to create a new System.Windows.Xps.Packaging.XpsDocument object from byte array, as I
Ok, so is it better to create my own components (Either inherit them from
While implementing transaction scope in mvc application. is it better to create a transaction
I am starting to write some javascript for my site to create a better
When creating a 3D array in C#, which is a better way to create
Is it considered better practice and/or more efficient to create a 'reset' function for
Is it better(what is the best practice) to create methods with a long list
i am trying to create slider movement graphics. The code explain better this. using
does anybody know of a secure 'read-once' local file access system? Or how one
When I use FlashBuilder to connect to a remote Java object using BlazeDS, FlashBuilder

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.