I would like to read a simple text file in objective-C (command line tool) this is my code
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
NSBundle *bundle = [NSBundle mainBundle];
NSString *aPath = [bundle pathForResource:@"data" ofType:@"txt"];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:aPath];
if (fileExists) {
NSLog(@"THERE!");
} else {
NSLog(@"NOT THERE!");
}
but I tried full path like /Users/Me/data or added data.txt into xcode but it just won't load the file, what am I missing? thank you!