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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:30:47+00:00 2026-05-16T11:30:47+00:00

I was wondering, what (if any) is the difference between creating objects using: NSThing

  • 0

I was wondering, what (if any) is the difference between creating objects using:

NSThing *thing = [[NSThing alloc] initWithObject:object];

vs

NSThing *thing = [[NSThing thingWithObject:object] retain];

Is there a difference in how the memory management works? Also, when is it common practice to use one vs 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-05-16T11:30:47+00:00Added an answer on May 16, 2026 at 11:30 am

    Allocating and initialising an object is slightly more efficient, because thingWithObject: will do an alloc, then init, then autorelease which you counter with a retain, so you add something to the autorelease pool. The first option only involves an alloc and a init.

    Personally, I use the explicit alloc when I want to be clear that the object’s lifetime will be handled by me, and I use the convenience methods (thingWithThing:) for any object that I won’t need outside of the scope it is created in.

    For example, explicitly allocating and initialising within a loop is generally preferred, so that you don’t flood the autorelease pool. I also use an explicit alloc+init rather than thingWithThing: + retain for objects that need to survive an iteration of the run loop.

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Don't know of anything pre-built, but you can write one… May 16, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer I think this MDC tutorial is what you're looking for:… May 16, 2026 at 5:50 pm
  • Editorial Team
    Editorial Team added an answer like everyone else said - IronRuby won't make your life… May 16, 2026 at 5:50 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Ive been wondering... in CSS are there any differences between creating a style class
I was just wondering if there is any difference between the two different new
I'm (finally) starting to learn regex, and I'm wondering if there's any notable difference
I'm using PHP + Oracle and was wondering if there are any recommendations on
Is there any difference between double dispatch and visitor pattern? I'm working with Java
I am wondering at the difference between declaring a variable as volatile and always
I don't know much about creating Makefiles, but I've been reading the make manual
I am wondering if it is possible to have a JSF handler and some
I have a table and am debating between 2 different ways to store information.
Applications I am using: Visual Studio 2008 (C#/ASP.NET) Visual Source Safe 8.0 IIS 5.1

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.