I’m trying to read data from 1.txt in my iphone project’s resources folder using the following code:
NSString *fileContent = [NSString stringWithContentsOfFile:[[NSString stringWithFormat:@"%d", currentLevel] stringByAppendingString:@".txt"] encoding:NSUTF8StringEncoding error:nil];
NSAssert(fileContent!=nil, @"file's contents are nil");
currentLevel is an integer which is initially set to 1. It doesn’t matter whether I replace [[NSString stringWithFormat:@”%d”, currentLevel] stringByAppendingString:@”.txt”] with @”1.txt” (for testing the first level) because both times NSAssert fails
why isn’t this working? I’ve imported 1.txt to xcode and it’s in the resources file. it’s not empty.
Try this: