Last active
August 12, 2018 18:23
-
-
Save nishabe/1e8531f8ee580b089aef1145369aa5c1 to your computer and use it in GitHub Desktop.
OBJC: Read text from File
This file contains hidden or 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*)readString{ | |
NSURL *filePath = [[NSBundle mainBundle] URLForResource:@"info" withExtension:@"txt"]; | |
NSString *path = [filePath path]; | |
NSString *content = @""; | |
if([[NSFileManager defaultManager] fileExistsAtPath:path]) { | |
// Do something here | |
content = [NSString stringWithContentsOfFile:path | |
encoding:NSUTF8StringEncoding | |
error:NULL]; | |
} | |
else { | |
NSLog(@"File not exits"); | |
} | |
return content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment