Read file contents

iOS, Mac OS is same.

NSString

NSError *error = nil;
NSString *body = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
if ( error )
{
   NSLog(@"Error %@", [error description]);
   return;
}

Be careful, this is for UTF-8 file. path is File path. body is result of file contents.

NSData

NSFileManager *fm = [NSFileManager defaultManager];
NSData *data = [fm contentsAtPath:[url path]];   // url is NSURL *

Use contentsAtPath