Marcel Hansemann
Marcel Hansemann

Reputation: 1019

Can I add the same object to two different arrays?

Is this valid:

 NSObject anObject = [[NSObject alloc] init];
 [array1 addObject:anObject];
 [array2 addObject:anObject];

My money is on yes, since I'm only adding references to the same object, or am I wrong here?

Upvotes: 0

Views: 394

Answers (1)

Piotr
Piotr

Reputation: 4963

Yes :) Dont forget to make it a mutable array

Upvotes: 6

Related Questions