I'm storing a WAV filename in an array, including the extenstion. When I try to load it it is requiring the extension be removed. If I substring the extension off it abends, while the seemingly same string works fine when hard-coded.
I also tried using the stringByDeletingPathExtension method, with the same crash.
This code causes a crash
NSString *fileName = [[currentWord.audioFile componentsSeparatedByString:@"."] objectAtIndex: 0];
SFCLog(@"fileName: %@",fileName);
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"wav"];
CFURLRef BaseURL = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
-[ViewController loadWord] [line 143] fileName: owe_fr
2012-08-20 17:50:21.561 Hello[8053:16a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
But this code executes
NSString *fileName = @"owe_fr";
SFCLog(@"fileName: %@",fileName);
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"wav"];
CFURLRef fluentBaseURL = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
OK I found it. A leading space in the stored filename version - you can see it in the log statement. I found it by logging like this (Markers to either side of the string):
SFCLog(@"fileName :%@:",fileName);
Which logged as:
-[ViewController loadWord] [line 144] fileName : about_fr:
Cheers, Sean