Question

Example:

NSData *fileData = [fileHandle readDataToEndOfFile];

Am I responsible for closing that file handle? (I think I'm not...but just 99.95% sure!)

Was it helpful?

Solution

You are not required to close the file handle, however, it is good practice to deallocate the NSFileHandle object when you are finished with it. This will ensure that the memory used by the application is kept to a minimum.

iOS Class Reference:

Note: The deallocation of an NSFileHandle object deletes its descriptor and closes the represented file or channel unless the NSFileHandle object was created with initWithFileDescriptor: or initWithFileDescriptor:closeOnDealloc: with NO as the parameter argument.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top