I'm trying to get all the text from a txt file into a string, but if I try to NSlog() this string, i get null. I think it's because of the path i'm trying to get the file at, but I can't seem to figure out what is wrong with the path. I know that i get the right navigationItem.title, so that is not the problem. The text file is in the main bundle in a subfolder called Øvelser/Text/"nameOfExercise".txt. I have pasted my code below:
- (void)viewDidLoad
{
[super viewDidLoad];
//Read from the exercise document
NSString *path = [[@"Øvelser/Text/" stringByAppendingString:self.navigationItem.title] stringByAppendingString:@".txt"];
if(path)
{
_exerciseDocument = [NSString stringWithContentsOfFile:path encoding: NSUTF8StringEncoding error:nil];
NSLog(@"%@", _exerciseDocument);
}
else
{
NSLog(@"error");
}
}