开发者

pathForResources returning (null)

开发者 https://www.devze.com 2023-03-17 15:04 出处:网络
I am using these lines of code N开发者_开发知识库SString *path = [[NSBundle mainBundle] pathForResource:@\"index\" ofType:@\"html\" inDirectory:@\"test\"];

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消