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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:27:00+00:00 2026-06-15T16:27:00+00:00

i have two nsmutablearray: @property (nonatomic, strong) NSMutableArray *calSeries; @property (nonatomic, strong) NSMutableArray *calSeries2Copy;

  • 0

i have two nsmutablearray:

@property (nonatomic, strong) NSMutableArray *calSeries;
@property (nonatomic, strong) NSMutableArray *calSeries2Copy;

then i do this:

self.calSeries = [self getSeries];
self.calSeries2Copy = [NSMutableArray arrayWithArray:self.calSeries];

the getSeries method fetchObject from the core data, but if i change an element in the calSeries, it change also in the calSeries2Copy, how i can create two array separately so as when i change an element in one array don’t change also in the other array?

  • 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-15T16:27:01+00:00Added an answer on June 15, 2026 at 4:27 pm

    Try this,

    self.calSeries2Copy = [[NSMutableArray alloc] initWithArray:self.calSeries copyItems:YES];
    

    As per documentation, this should copy if you have implemented NSCopying protocol.

    flag

    If YES, each object in array receives a copyWithZone: message to
    create a copy of the object—objects must conform to the NSCopying
    protocol. In a managed memory environment, this is instead of the
    retain message the object would otherwise receive. The object copy is
    then added to the returned array.

    If NO, then in a managed memory environment each object in array
    simply receives a retain message when it is added to the returned
    array.

    Discussion

    After an immutable array has been initialized in this way,
    it cannot be modified.

    The copyWithZone: method performs a shallow copy. If you have a
    collection of arbitrary depth, passing YES for the flag parameter will
    perform an immutable copy of the first level below the surface. If you
    pass NO the mutability of the first level is unaffected. In either
    case, the mutability of all deeper levels is unaffected.

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

Sidebar

Related Questions

Suppose I have @interface A : NSObject @property (nonatomic, strong) NSMutableArray *array; @end Later
Say I have two properties defined as such: @property (nonatomic, strong) UITableView *parentTableView; @property
I have two arrays, both full of NSString objects like this: NSMutableArray *titles =
Have two folders with approx. 150 java property files. In a shell script, how
I have two NSMutableArray: arrayone and arraytwo arrayone and arraytwo are full of objects,
I have two NSMutableArrays: NSMutableArray* currentMessages NSMutableArray* items I am trying to copy the
Possible Duplicate: deep copy NSMutableArray in Objective-C ? I have two arrays of length
Let say if there is already class properties of @property (strong, nonatomic) JJNode *leftChild;
So I have two objects, Invoice and InvoiceLineItem. InvoiceLineItem has a property called cost
I have two simple NSMutableArray that consists of few objects. Some of these objects

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.