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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:52:28+00:00 2026-05-24T05:52:28+00:00

So assume I declared an object and created a retained property for it which

  • 0

So assume I declared an object and created a retained property for it which is synthesized. So something like that in the header file:

NSArray *array;
@property (retain)....

After it is synthesized, I called release in the dealloc.

Now in the init method, if I want to also dynamically allocate that array, what do I do in terms of releasing it? So:
array = [[NSArray alloc] initWithObjects...

How do I keep the object retained as long as the class is running without leaking?

Thank you

  • 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-24T05:52:28+00:00Added an answer on May 24, 2026 at 5:52 am
    self.array = [[[NSArray alloc] initWithObjects:...] autorelease];
    

    or

    NSArray *newArray = [[NSArray alloc] initWithObjects:...];
    self.array = newArray;
    [newArray release];
    

    With both options, you additionally have to call [array release]; in dealloc.

    By using its setter method, you normally don’t have do worry about retains and releases.

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

Sidebar

Related Questions

Assume I declared an Array isFind[] like this, bool[] isFind = new bool[5]; for
Assume you are doing something like the following List<string> myitems = new List<string> {
Can I assume an object declared in unnamed namespace to be equivalent to as
Assume that the int variables i and j have been declared, and that n
Assume that we have N erlang nodes, running same application. I want to share
Assume I have created a compiled re: x = re.compile('^\d+$') Is there a way
I recently tried to create an object like this: var carousel = { $slider:
I have the following declared on a Singleton type object named CicApplication: internal static
If one is designing an interface like ILookup (for simplicity, assume it's simply ICheckIfContained
Assume we have a button declared in XML : <button x:Class=A Content=click me Name=button

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.