Вопрос

When I call readDataOfLength: on an NSFileHandle instance, do I need to release the returned NSData? Currently I'm not, but I would like to get rid of this nagging doubt.

Это было полезно?

Решение

Nope. Cocoa's memory management rules say that you only own (and thus need to release) objects returned from a method whose name contains one of "new", "alloc", "retain", or "copy" (NARC). Since that method contains none of those, you know you don't need to release it.

Другие советы

The standard that is observed very consistently within Objective C libraries is that a method beginning with "alloc" or "copy" (and, I'm thinking, some other obscure verb) returns a retained object, while everything else returns an autoreleased object.

Any exceptions should be well-documented in the specs.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top