Disallows further access to the represented file or communications channel and signals end of file on communications channels that permit writing.
- iOS 2.0–13.0Deprecated
- macOS 10.0–10.15Deprecated
- Mac Catalyst 13.0+Beta
- tvOS 9.0–13.0Deprecated
- watchOS 2.0–6.0Deprecated
If the file handle object owns its file descriptor, it automatically closes that descriptor when it is deallocated. If you initialized the file handle object using the
init(file method, or you initialized it using the
init(file and passed
false for the
flag parameter, you can use this method to close the file descriptor; otherwise, you must close the file descriptor yourself.
After calling this method, you may still use the file handle object but must not attempt to read or write data or use the object to operate on the file descriptor. Attempts to read or write a closed file descriptor raise an exception.