objective c - What are the differences between copy ,mutableCopy and assignment? -


i thought understood difference between copy , mutablecopy. today doubt myself. still don't understand.

nsarray *arrayb = [nsarray arraywithobject:@"a"]; nsarray *arraya = [arrayb copy]; nsarray *arrayc = [arrayb mutablecopy]; nsarray *arrayd = arrayb; 

when make changes arraya, arrayc or arrayd,will arrayb have same change 1 of changed arraya, arrayc , arrayd?

nsarray *arrayb = [nsarray arraywithobject:@"a"]; // can't modify now

nsarray *arraya = [arrayb copy]; // create copy of array b xerox. if change in xerox not reflect original copy

nsarray *arrayc = [arrayb mutablecopy]; // mutable copy can make changes in , have change nsarray nsmutablearray here mutable copy.

nsarray *arrayd = arrayb;// change made in arrayd reflect arrayb arrayd nsarray (immutable) can not make changes in arrayd

hope clear things you.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -