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

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top