I've been trying to load a simple text file in a unit test for an iOS app.
NSString* resourcePath = [[NSBundle mainBundle] pathForResource: @"stopPointsInCircleData" ofType:@"txt"];
NSString* stopPointData = [NSData dataWithContentsOfFile: resourcePath];
My problem is that pathForResource returns nil.
The file stopPointsInCircleData.txt is located in the directory of the test code and the file is listed correctly under "Copy Bundle Resources" in the "Build Phases" of the test target.
I've tried to relax the search by setting ofType to nil, but thet didn't work either.
Any help is very much apprechiated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…