Search code examples
objective-ccocoansdatansfilehandle

Does NSFileHandle -readDataOfLength: return autoreleased NSData?


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.


Solution

  • 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.