I have read the answer for difference between deep copy and shallow copy from the post, What is the difference between a deep copy and a shallow copy? . Now I got some doubt that when we made a shallow copy by
newArray = [NSmutableArray arrayWithArray:oldArray];
the new array will point to oldArray. (As from the figure). Now what happen when I remove object from newArray? As from figure, it should remove same element from oldArray too !!! It seems like
newArray = oldArray
is a shallow copy and newArray = [NSmutableArray arrayWithArray:oldArray];
is deep copy. Is it right?