Question

I am using below code

// it is showing nil for path

NSString *path = [[NSBundle mainBundle] pathForResource:@"filetext.doc" ofType:nil];
NSURL *url1 = [NSURL fileURLWithPath:path];

// it is showing working

NSString *path = [[NSBundle mainBundle] pathForResource:@"filetext.txt" ofType:nil];
NSURL *url1 = [NSURL fileURLWithPath:path];

Please help what is the issue

Était-ce utile?

La solution

According to the docs, the method returns nil if the file cannot be found. The conclusion, therefore, is that the file is missing. Check your project's Build Phases/Copy Bundle Resources to ensure that the file is actually present because in all likelihood it is not.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top