#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
When I run it on my device it gives me the following error:
Thread 1:Program received signal: "SIGABRT".
How do i fix this?
2011-11-10 14:59:43.487 AVMultiPlayer[13554:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(0x3102a8bf 0x381cf1e5 0x3102a7b9 0x3102a7db 0x3803e06f 0x3803e00b 0x2dc9 0x2b5d 0x30f84435 0x32fdf9eb 0x32fdf9a7 0x32fdf985 0x32fdf6f5 0x32fdf321 0x32fde485 0x32fddf01 0x32fc44ed 0x32fc3d2d 0x33bafe13 0x30ffe553 0x30ffe4f5 0x30ffd343 0x30f804dd 0x30f803a5 0x33baefed 0x32ff2743 0x25b5 0x2574)
terminate called throwing an exception(gdb)
That is what the output box tells me.
Somewhere in your code you use
[NSURL initFileURLWithPath:]
but you pass a nil path value.
Check your string.
Your path is nil on the device.
First, try cleaning your project.
Then, ensure the files are being copied over in the "Copy Bundle Resources" build phase
And as Anna Karenina suggested, make sure the names are being handled in a case sensitive manner.
- (void)playOnce:(NSString )aSound { // <-- Write NSString* here. Check it, it may be null
// or "aSound".caf is not include in your project or is just not checked to be part of your project (remove it and add it again)
NSString *path = [[NSBundle mainBundle] pathForResource:aSound ofType:@"caf"];
AVAudioPlayer theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[theAudio setDelegate: self];
[theAudio setNumberOfLoops:0];
[theAudio setVolume:1.0];
[theAudio play];
}
The important error is 'NSInvalidArgumentException'
, and as the error says, the problem is that one of the strings is null that shouldn't be. Depending on what you're trying to do, this post may be of help: Proper use of UIApplicationMain