So I've been trying to get my app to play a subtle sound when one viewController slide-transitions into another but I'm having a problem. I've done troubleshooting for the past few days to narrow down the issue and I've narrowed it down to the following code:
When I run my app the second line prints out as 'soundPath = (null)' and the if statement to run the rest of the code fails because the next NSLog never prints. Here's that code for reference if it helps any.
From what I can gather, the file isn't being found, even though it definitely exists in my project with the exact same spelling, case, and file format extension. Any ideas what could be going wrong?
Code:
NSString *soundPath = [[NSBundle mainBundle] pathForResource: @"slide" ofType: @"aif"];
NSLog(@"soundPath = %@", soundPath);
When I run my app the second line prints out as 'soundPath = (null)' and the if statement to run the rest of the code fails because the next NSLog never prints. Here's that code for reference if it helps any.
Code:
if ([[NSFileManager defaultManager] fileExistsAtPath:soundPath])
{
NSLog(@"slide.aif loaded");
NSURL* slideSoundURL = [NSURL fileURLWithPath:soundPath];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)slideSoundURL, &slideSound);
}
From what I can gather, the file isn't being found, even though it definitely exists in my project with the exact same spelling, case, and file format extension. Any ideas what could be going wrong?