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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:07:30+00:00 2026-06-13T06:07:30+00:00

I have an instance array that I will end up changing depending on user

  • 0

I have an instance array that I will end up changing depending on user settings. I set the to a immutable NSArray:

@property (strong, nonatomic) NSArray *pointArray;

When i need to change the array, i’ve been doing this:

-(void)changePointArray
{
    NSMutableArray *tempArray = [NSMutableArray arrayWithArray:self.pointArray];

    // Make changes

    self.pointArray = [NSArray arrayWithArray:tempArray];
}

Is this acceptable practice or am i creating a leak? Should i just typecast it instead:

self.pointArray = (NSArray *)tempArray;

or do even need to worry about setting a NSMutableArray to a NSArray?

self.pointArray = tempArray;
  • 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-13T06:07:32+00:00Added an answer on June 13, 2026 at 6:07 am

    No, there is no leak (with respect to memory management).

    Your code is absolutely ok if your goal is to not expose the mutual array in your public interface.

    If, however, you don’t care about abstraction here (or if that property is not public), it would be easier to just declare the property of type NSMutualArray * in the first place.

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

Sidebar

Related Questions

I have an app (using retain/release, not GC) that maintains an NSArray instance variable,
I have code in cake php that looks like: public $ceff_instance = array(); public
I have an NSMutableArray. It's members eventually become members of an array instance in
I have the following code in config: <?php return array( 'di' => array( 'instance'
I have an array for instance, Array { 3.0 at Index 0 2.0 at
For an instance you have an array: $unsorted = array( 'desert' => array( 'time'
How could I accomplish copying one jagged array to another? For instance, I have
class A attr_accessor :dab .... end Now I have an array of instances of
I'm trying to create a Messages object that inherits Array. The messages will gather
I have a multi-dimensional array that I'd like to use for building an xml

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.