Reading a file into a string is very similar:
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { @autoreleasepool { NSError *error = nil; NSString *str = [[NSString alloc] initWithContentsOfFile:@"/etc/resolv.conf" encoding:NSASCIIStringEncoding error:&error]; if (!str) { NSLog(@"read failed: %@", [error localizedDescription]); } else { NSLog(@"resolv.conf looks like this: %@", str); } } return 0; }