Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>initWithArray:</code> initializes a new array and places in it all the objects contained in a given array. This means that each object in the given array will receive a <code>retain</code>. Hence, if you edit an object in the new array, you will modify that object even in the given array. (see shallow copy)</p> <p>On the other hand, <code>initWithArray:copyItems:</code>, if <code>YES</code> is passed as second argument, will provide a deep copy.</p> <p>Beware that if you need to deeply copy an entire nested data structure then this approach will not suffice. (see the Apple <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/instm/NSArray/initWithArray:copyItems:" rel="nofollow">documentation</a>)</p> <p>Example:</p> <pre><code>NSMutableString *s = [[NSMutableString alloc] initWithString:@"hello"]; NSArray *a = @[s]; NSArray *b = [[NSArray alloc] initWithArray:a]; [a[0] appendString:@" there"]; </code></pre> <p>after these lines the arrays <code>a</code> and <code>b</code> will contain the mutable string "hello there"</p> <pre><code>NSMutableString *s = [[NSMutableString alloc] initWithString:@"hello"]; NSArray *a = @[s]; NSArray *c = [[NSArray alloc] initWithArray:a copyItems:YES]; [a[0] appendString:@" there"]; </code></pre> <p>while after these lines the array <code>c</code> will contain the mutable string "hello" and the array <code>a</code> will contain the mutable string "hello there"</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload