Changes

Working with Files in Objective-C

23 bytes added, 20:06, 31 March 2011
Reading and Writing Files with NSFileManager
[filemgr createFileAtPath: @"/tmp/newfile.txt" contents: databuffer attributes: nil];
</pre>
<google>IOSBOX</google>
In the above example we have essentially copied the contents from an existing file to a new file. This, however, gives us no control over how much data is to be read or written and does not allow us to append data to the end of an existing file. If the file ''/tmp/newfile.txt'' in the above example had already existed it, and any data it contained, would have been overwritten by the contents of the source file. Clearly some more flexible mechanism is required. This is provided by the Foundation Framework in the form of the ''NSFileHandle'' class.