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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:41:02+00:00 2026-05-16T08:41:02+00:00

I know that if I get an object, for example an NSArray, with a

  • 0

I know that if I get an object, for example an NSArray, with a method like [NSArray array], it will be autoreleased. So I don’t have to do a release myself. My question is, do I have to retain it after I get it this way? I wouldn’t have thought so, since the count starts at 1 and it won’t be released until the pool is released, but I’ve gotten a few bad access errors from these objects when I don’t. So to fix them, I’m retaining these objects, and then releasing them myself later. What’s going on in this case? Am I still not grasping objective-c memory management?

  • 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-16T08:41:03+00:00Added an answer on May 16, 2026 at 8:41 am

    I heartily advise you to stop thinking about retain counts. Instead, think about ownership: do you want to claim a piece of ownership of an instance (i.e. do you want to make sure it stays around until you say otherwise)? If so, -retain it. Otherwise, do not -retain it. Anytime you retain an ownership interest in an instance, you must -release that interest some time in the future or the instance will never be deallocated.

    You can assume that any method that doesn’t match the alloc/new/copy pattern returns instances in which you do not have an ownership interest. If you want them to stick around beyond the current stack frame, retain them.

    For this and all other Objective-C memory questions, read the Memory Management Programming Guide. Then re-read it. Again. It is the authoritative reference on the subject. It will be your friend.

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

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • 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 alright I figured it out. Instead of directly changing the… May 16, 2026 at 10:15 am
  • Editorial Team
    Editorial Team added an answer This should do it: NSLog(@"Images in bundle are:"); NSString *imageExtension… May 16, 2026 at 10:15 am
  • Editorial Team
    Editorial Team added an answer Probably the class has not included by the delphi linker… May 16, 2026 at 10:15 am

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

I know this has been discussed ad-nauseum but I just don't get some of
I know there's no one answer to this question, but I'd like to get
If I have a Range object--for example, let's say it refers to cell A1
I want to make a custom Array object that recieves a number as index,
I know that might sound like a stupid question since it's a trivial feature
I have a pointer to a COM object that implements an undocumented interface. I
I wrote a flex application that get the host string from the browser using
I wish to create a subtree from an hclust object. For example, let's say
I have a model that has several properties. The properties can be primitive (String)
I know this question must have been covered endless of times, but I've searched

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.