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
Post a Comment