One Logo Pool Ball
Foundation · IOS API REFERENCE

FileHandle

class · SDK 27.1

class FileHandle

Members (47)

get

readCompletionNotification

TypeScript
static get readCompletionNotification(): NSNotification_Name
Swift declaration
class let readCompletionNotification: NSNotification.Name
init

init

TypeScript
static initForReadingAtPath(path: string): (FileHandle) | null
Swift declaration
convenience init?(forReadingAtPath path: String)
init · iOS 4.0+

init

TypeScript
static initForReadingFrom(url: string): FileHandle
Swift declaration
convenience init(forReadingFrom url: URL) throws
init

init

TypeScript
static initForUpdatingAtPath(path: string): (FileHandle) | null
Swift declaration
convenience init?(forUpdatingAtPath path: String)
init · iOS 4.0+

init

TypeScript
static initForUpdating(url: string): FileHandle
Swift declaration
convenience init(forUpdating url: URL) throws
init

init

TypeScript
static initForWritingAtPath(path: string): (FileHandle) | null
Swift declaration
convenience init?(forWritingAtPath path: String)
init · iOS 4.0+

init

TypeScript
static initForWritingTo(url: string): FileHandle
Swift declaration
convenience init(forWritingTo url: URL) throws
get

nullDevice

TypeScript
static get nullDevice(): FileHandle
Swift declaration
class var nullDevice: FileHandle { get }
get

standardError

TypeScript
static get standardError(): FileHandle
Swift declaration
class var standardError: FileHandle { get }
get

standardInput

TypeScript
static get standardInput(): FileHandle
Swift declaration
class var standardInput: FileHandle { get }
get

standardOutput

TypeScript
static get standardOutput(): FileHandle
Swift declaration
class var standardOutput: FileHandle { get }
method

acceptConnectionInBackgroundAndNotify

TypeScript
acceptConnectionInBackgroundAndNotify(): void
Swift declaration
func acceptConnectionInBackgroundAndNotify()
method

acceptConnectionInBackgroundAndNotify

TypeScript
acceptConnectionInBackgroundAndNotifyForModes(modes?: (Array<RunLoop_Mode>) | null): void
Swift declaration
func acceptConnectionInBackgroundAndNotify(forModes modes: [RunLoop.Mode]?)
method · iOS 13.0+

close

TypeScript
close(): void
Swift declaration
func close() throws
method · iOS 2.0+ · Deprecated in iOS 100000.0

closeFile

TypeScript
closeFile(): void
Swift declaration
func closeFile()
init

init

TypeScript
static initCoder(coder: NSCoder): (FileHandle) | null
Swift declaration
init?(coder: NSCoder)
init

init

TypeScript
static initFileDescriptor(fd: number): FileHandle
Swift declaration
convenience init(fileDescriptor fd: Int32)
init

init

TypeScript
static initFileDescriptorCloseOnDealloc(fd: number, closeopt: boolean): FileHandle
Swift declaration
init(fileDescriptor fd: Int32, closeOnDealloc closeopt: Bool)
method · iOS 2.0+ · Deprecated in iOS 100000.0

readData

TypeScript
readData(length: number): ArrayBuffer
Swift declaration
func readData(ofLength length: Int) -> Data
method · iOS 2.0+ · Deprecated in iOS 100000.0

readDataToEndOfFile

TypeScript
readDataToEndOfFile(): ArrayBuffer
Swift declaration
func readDataToEndOfFile() -> Data
method

readInBackgroundAndNotify

TypeScript
readInBackgroundAndNotify(): void
Swift declaration
func readInBackgroundAndNotify()
method

readInBackgroundAndNotify

TypeScript
readInBackgroundAndNotifyForModes(modes?: (Array<RunLoop_Mode>) | null): void
Swift declaration
func readInBackgroundAndNotify(forModes modes: [RunLoop.Mode]?)
method

readToEndOfFileInBackgroundAndNotify

TypeScript
readToEndOfFileInBackgroundAndNotify(): void
Swift declaration
func readToEndOfFileInBackgroundAndNotify()
method

readToEndOfFileInBackgroundAndNotify

TypeScript
readToEndOfFileInBackgroundAndNotifyForModes(modes?: (Array<RunLoop_Mode>) | null): void
Swift declaration
func readToEndOfFileInBackgroundAndNotify(forModes modes: [RunLoop.Mode]?)
method · iOS 2.0+ · Deprecated in iOS 100000.0

seekToEndOfFile

TypeScript
seekToEndOfFile(): number
Swift declaration
func seekToEndOfFile() -> UInt64
method · iOS 2.0+ · Deprecated in iOS 100000.0

seek

TypeScript
seekToFileOffset(offset: number): void
Swift declaration
func seek(toFileOffset offset: UInt64)
method · iOS 13.0+

seek

TypeScript
seekToOffset(offset: number): void
Swift declaration
func seek(toOffset offset: UInt64) throws
method · iOS 13.0+

synchronize

TypeScript
synchronize(): void
Swift declaration
func synchronize() throws
method · iOS 2.0+ · Deprecated in iOS 100000.0

synchronizeFile

TypeScript
synchronizeFile(): void
Swift declaration
func synchronizeFile()
method · iOS 13.0+

truncate

TypeScript
truncate(offset: number): void
Swift declaration
func truncate(atOffset offset: UInt64) throws
method · iOS 2.0+ · Deprecated in iOS 100000.0

truncateFile

TypeScript
truncateFile(offset: number): void
Swift declaration
func truncateFile(atOffset offset: UInt64)
method

waitForDataInBackgroundAndNotify

TypeScript
waitForDataInBackgroundAndNotify(): void
Swift declaration
func waitForDataInBackgroundAndNotify()
method

waitForDataInBackgroundAndNotify

TypeScript
waitForDataInBackgroundAndNotifyForModes(modes?: (Array<RunLoop_Mode>) | null): void
Swift declaration
func waitForDataInBackgroundAndNotify(forModes modes: [RunLoop.Mode]?)
method · iOS 2.0+ · Deprecated in iOS 100000.0

write

TypeScript
write(data: ArrayBuffer): void
Swift declaration
func write(_ data: Data)
get

availableData

TypeScript
get availableData(): ArrayBuffer
Swift declaration
var availableData: Data { get }
get

fileDescriptor

TypeScript
get fileDescriptor(): number
Swift declaration
var fileDescriptor: Int32 { get }
get · iOS 2.0+ · Deprecated in iOS 100000.0

offsetInFile

TypeScript
get offsetInFile(): number
Swift declaration
var offsetInFile: UInt64 { get }
get · iOS 5.0+

readabilityHandler

TypeScript
get readabilityHandler(): (((arg0: FileHandle) => Promise<void>)) | null
Swift declaration
var readabilityHandler: (@Sendable (FileHandle) -> Void)? { get set }
set · iOS 5.0+

readabilityHandler

TypeScript
set readabilityHandler(value: (((arg0: FileHandle) => void)) | null)
Swift declaration
var readabilityHandler: (@Sendable (FileHandle) -> Void)? { get set }
get · iOS 5.0+

writeabilityHandler

TypeScript
get writeabilityHandler(): (((arg0: FileHandle) => Promise<void>)) | null
Swift declaration
var writeabilityHandler: (@Sendable (FileHandle) -> Void)? { get set }
set · iOS 5.0+

writeabilityHandler

TypeScript
set writeabilityHandler(value: (((arg0: FileHandle) => void)) | null)
Swift declaration
var writeabilityHandler: (@Sendable (FileHandle) -> Void)? { get set }
method · iOS 13.4+

read

TypeScript
read(count: number): (ArrayBuffer) | null
Swift declaration
func read(upToCount count: Int) throws -> Data?

Reads data synchronously up to the specified number of bytes. - Parameter count: The number of bytes to read from the file handle. - Returns: The data available through the receiver up to a maximum of `count` bytes, or the maximum size that can be represented by an `NSData` object, whichever is the smaller. If the handle represents a file, this method returns the data obtained by reading `count` bytes starting at the current file pointer. If `count` bytes aren't available, this method returns the data obtained by reading bytes up to the end of the file. If the handle represents a communications channel, this method reads up to `count` bytes from the channel.

get · iOS 15.0+

bytes

TypeScript
get bytes(): FileHandle_AsyncBytes
Swift declaration
var bytes: FileHandle.AsyncBytes { get }

The file's contents, as an asynchronous sequence of bytes. Use the `for`-`await`-`in` syntax to iterate over the bytes in this sequence. For text files, you can also use its `characters`, `unicodeScalars`, or `lines` properties to retrieve the contents in a more convenient format. > Tip: Rather than creating a ``FileHandle`` to read a file asynchronously, you can instead use a `file://` URL in combination with the `URL.resourceBytes` property.

method · iOS 13.4+

write

TypeScript
writeContentsOf(data: ArrayBuffer): void
Swift declaration
func write<T>(contentsOf data: T) throws where T : DataProtocol

Writes the specified data synchronously to the file handle. - Parameter data: The data to write to the file handle. If the handle represents a file, writing takes place at the file pointer's current position. After it writes the data, the method advances the file pointer by the number of bytes written. This method throws an error if the file descriptor is closed or isn't valid, if the handle represents an unconnected pipe or socket endpoint, if there isn't any free space on the file system, or if any other writing error occurs.

method · iOS 13.4+

offset

TypeScript
offset(): number
Swift declaration
func offset() throws -> UInt64

Gets the position of the file pointer within the file. - Returns: The position of the file pointer within the file. Throws an error if called on a file handle representing a pipe or socket, or if the file descriptor is closed.

method · iOS 13.4+

readToEnd

TypeScript
readToEnd(): (ArrayBuffer) | null
Swift declaration
func readToEnd() throws -> Data?

Reads the available data synchronously up to the end of file or maximum number of bytes. - Returns: The data available through the file handle up to the maximum size that can be represented by an `NSData` object or, if a communications channel, until an end-of-file indicator is returned. This method invokes ``readData(ofLength:)`` as part of its implementation.

method · iOS 13.4+

seekToEnd

TypeScript
seekToEnd(): number
Swift declaration
@discardableResult func seekToEnd() throws -> UInt64

Places the file pointer at the end of the file referenced by the file handle and returns the new file offset. - Returns: The file offset with the file pointer at the end of the file. This is therefore equal to the size of the file. Throws an error if called a file handle representing a pipe or socket, or if the file descriptor is closed.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

FileHandle.init()

inherited init: cannot prove legal (class declares 11 custom initializers)

All Foundation types →