ARC - why do object pointers require explicit ownership type in function definitions?

断了今生、忘了曾经 提交于 2019-12-05 19:03:51

To expand on Jeremy's answer, ARC had two primary goals when designed:

  • make memory management as fully automatic as possible in pure Objective-C code while also preserving or maximizing efficiency (in fact, ARC can be more efficient than manual retain release).

  • require exactly specific declaration of memory management intent when crossing the boundary between C and Objective-C.

As well, the implementation of ARC is extremely conservative. That is, anywhere where the behavior has traditionally been "undefined", ARC will spew a warning.

Thus, in this case, the declaration of intent is required so that the compiler can apply a consistent and specific set of memory management rules to the contents of the array.

Because ARC needs to know whether to insert retain/release calls for you to avoid memory leaks.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!