pathForResources returning (null)
I am using these lines of code
N开发者_开发知识库SString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"test"];
NSLog(@"%@", path);
And the NSLog is printing out (null).
The file I'm trying to read is index.html. It is in the test folder which is in my project folder. Does anyone know why path returns (null).
Thanks
Clinton
This method will return nil if your resource can't be found. Try another one like -(NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)subpath
specifying 'test' as the directory name.
Also make sure your file is included into your app bundle...
精彩评论