NSString immutable allows to change its values?

后端 未结 3 499
旧巷少年郎
旧巷少年郎 2020-12-19 11:07

The code below compiles and runs, BUT according to all iPhone development books and Apple documentation it shouldnt! Can someone please explain to me how come immutable NSS

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 11:39

    TEST and TEST2 are two different strings pointed to by the *test pointer.

    You are not changing the contents of the explicitly allocated NSString object from the first line of code but pointing *test to another object.

提交回复
热议问题