When I run the code below
NSString *chemin;
chemin = [NSString stringWithFormat:@"chapitre0%d", [sender tag]];
NSLog(@"chemin : %@",chemin);
[detailChapitre loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:chemin ofType:@"html"]isDirectory:NO]]];
I got :
‘NSInvalidArgumentException’, reason: ‘* -[NSURL initFileURLWithPath:isDirectory:]: nil string parameter’
but *chemin is initialized to the right value in the log.
Certainly a noob question,
Thx for your help
This could be it, the
cheminvariable might have the correct chapter but the path might be wrong. So when you pass the wrong filepath toNSURLit would have returnednullwhich inturn would have caused the crash.First get the absolute path like so –