For the More Curious: Reading and Writing to the Filesystem
In addition to archiving and NSData’s binary read and write methods, there are a few more methods for transferring data to and from the filesystem. One of them, Core Data, is coming up in Chapter 23. A couple of others are worth mentioning here.
You have access to the standard file I/O functions from the C library. These functions look like this:
FILE *inFile = fopen("textfile", "rt"); char *buffer = malloc(someSize); fread(buffer, byteCount, 1, inFile); FILE *outFile = fopen("binaryfile", "w"); fwrite(buffer, byteCount, 1, outFile);
However, you will not see these functions used much because there are more convenient ways of reading and writing binary and text data. ...
Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.