Skip to content

Instantly share code, notes, and snippets.

@jenhausu
Created May 2, 2015 11:45
Show Gist options
  • Save jenhausu/fa543b2e497b5c2043d5 to your computer and use it in GitHub Desktop.
Save jenhausu/fa543b2e497b5c2043d5 to your computer and use it in GitHub Desktop.
讀外面的檔案
NSString *path = [[NSBundle mainBundle] pathForResource:@"SleepTypeExplanation"
ofType:@"rtf"];
NSString *fileContent = [NSString stringWithContentsOfFile:path
encoding:NSUTF32StringEncoding
error:&error];
NSURL *url = [NSURL fileURLWithPath:@"SleepTypeExplanation.rtf"];
NSString *fileContent = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
if (fileContent == nil) {
// an error occurred
NSLog(@"Error reading file at %@\n%@", path, [error localizedFailureReason]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment