I use to create such sounds:
NSString *explosionsoundpath = [[NSBundle mainBundle] pathForResource:@"explosion" ofType:@"caf"];
CFURLRef explosionurl = (CFURLRef ) [NSURL fileURLWithPath:explosionsoundpath];
AudioServicesCreateSystemSoundID (explosionurl, &explosion1a);
AudioServicesCreateSystemSoundID (explosionurl, &explosion1b);
where explosion1a and explosion1b are instance variables declared in the .h file with:
SystemSoundID explosion1a;
Whenever I try to make this process in an array like this
NSString *plasmasoundpath = [[NSBundle mainBundle] pathForResource:@"plasmasound" ofType:@"caf"];
CFURLRef plasmaurl = (CFURLRef ) [NSURL fileURLWithPath:plasmasoundpath];
SystemSoundID plasmalaunch1;
AudioServicesCreateSystemSoundID (plasmaurl, &plasmalaunch1);
[self.plasmasounds addObject:plasmalaunch1];
I get a warning:
"Passing argument 1 of addObject makes pointer from integer without a cast.
If I put the character and before plasmalaunch1 in the addObject argument, I get
incompatible pointer type warning.
I am trying to create an array of sound effects that I can play later by calling:
SystemSoundID sound = [self.plasmasounds objectAtIndex:i];
AudioServicesPlaySystemSound(sound);
Recommendations on how to make this work (or the best way to solve this problem) are appreciated!
source
share