-
-
Save jenhausu/fa543b2e497b5c2043d5 to your computer and use it in GitHub Desktop.
讀外面的檔案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *path = [[NSBundle mainBundle] pathForResource:@"SleepTypeExplanation" | |
ofType:@"rtf"]; | |
NSString *fileContent = [NSString stringWithContentsOfFile:path | |
encoding:NSUTF32StringEncoding | |
error:&error]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *url = [NSURL fileURLWithPath:@"SleepTypeExplanation.rtf"]; | |
NSString *fileContent = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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