Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'

I am scratching my head as to what is happening here.....The print plugin is not working... I am trying to add a printer plugin to an application..after mapping up my xml and loading html file, I do not see an error in Xcode. However, as I run the application it crashes and the log states :

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter'

I am worried as I am unable to overcome it since the last 24 hours...Any help will be great..or if someone can let me know of how to exactly get a printer plugin working in my app will be good....The code I am using is

// Set the base URL to be the www directory.
NSString* wwwFilePath = [[NSBundle mainBundle] pathForResource:@"www" ofType:nil];
NSURL*    baseURL     = [NSURL fileURLWithPath:wwwFilePath];
like image 436
Som Avatar asked Jun 11 '26 15:06

Som


1 Answers

There is no need to post so much code. Just post relevant code which are the following two lines:

NSString* wwwFilePath = [[NSBundle mainBundle] pathForResource:@"www" ofType:nil];
NSURL*    baseURL     = [NSURL fileURLWithPath:wwwFilePath];

The problems is that wwwFilePath is nil which means that you do not have a file named www in your app bundle.

Either add the missing file or update the name of the file in the call to pathForResource:ofType: with the proper filename.

BTW - the two lines can simply be:

NSURL *basEURL = [[NSBundle mainBundle] URLForResource:@"www" withExtension:nil];

but again you still need to pass in a valid filename/extension.

like image 86
rmaddy Avatar answered Jun 13 '26 11:06

rmaddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!