File Handle Not Closed (ARCH9080)
Esta página aún no está disponible en tu idioma.
Key swift.performance.file-handle-not-closed · Severity error · Category performance
Flags FileHandle / InputStream / OutputStream opened without close() (or a defer that closes it) on the same path.
Incorrect
Section titled “Incorrect”let h = try FileHandle(forReadingFrom: url)let data = h.readDataToEndOfFile()Correct
Section titled “Correct”let h = try FileHandle(forReadingFrom: url)defer { try? h.close() }Close the handle in a defer right after opening it.