更新时间:2022-04-09 05:25:45
NARC! :)
如果您调用的方法包含 N ew, A lloc, R 容器或 C opy ,那么您必须release
或autorelease
.否则,请不要触摸它.
If you invoked a method that contains N ew, A lloc, R etain, or C opy, then you must release
or autorelease
. Otherwise you don't touch it.
当然,文档中明确指出的任何内容都比这条规则重要.
Of course, anything the documentation explicitly says trumps this rule.
另一件事是,当您处理C函数时,NARC规则仍然适用,但还会获得Create规则:如果该函数包含"create",则您负责CFReleasing或释放返回的数据.
The other thing is that when you're dealing with C function the NARC rule still applies, but also gets the Create rule: if the function contains "create", then you're responsible for CFReleasing or freeing the returned data.