Changes

Jump to: navigation, search

Working with Files in Swift on iOS 8

31 bytes added, 04:26, 10 November 2016
FileHandle File Offsets and Seeking
== FileHandle File Offsets and Seeking ==
<htmlet>adsdaqbox_flow</htmlet>
FileHandle objects maintain a pointer to the current position in a file. This is referred to as the offset. When a file is first opened the offset is set to 0 (the beginning of the file). This means that any read or write operations performed using the FileHandle instance methods will take place at offset 0 in the file. To perform operations at different locations in a file (for example to append data to the end of the file) it is first necessary to seek to the required offset. For example to move the current offset to the end of the file, use the seekToEndOfFile method. Alternatively, seek(toFileOffset:) allows you to specify the precise location in the file to which the offset is to be positioned. Finally, the current offset may be identified using the offsetInFile method. In order to accommodate large files, the offset is stored in the form of an unsigned 64-bit integer.

Navigation menu