Difference between these two NSString methods

前端 未结 5 1405
广开言路
广开言路 2021-01-05 08:59

So I just got asked this at an interview today and after some googling am still unable to figure out the answer (in fact I couldn\'t even find any code at all which used the

5条回答
  •  我在风中等你
    2021-01-05 09:47

    The only thing I can imagine is that:

    1. Won't allocate memory since it is not made with alloc. It is a constant (an empty string) made by the system and doesn't need to be released.

    2. You allocate the memory for the NSString yourself which means you have to keep track if the NSString still 'lives' or not when you are done with it, and thus need to release it.

提交回复
热议问题