0

例子:

NSData *fileData = [fileHandle readDataToEndOfFile];

我是否负责关闭该文件句柄?(我想我不是......但只是 99.95% 肯定!)

4

1 回答 1

2

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.

于 2010-10-23T15:34:03.963 回答