Hello, guys.
I want to play two sounds, but the last one only after the first ends.
I'm using AudioServicesAddSystemSoundCompletion like that:
NSArray *data = [NSArray arrayWithObjects:target, callback, nil];
NSString *soundPath = [bundle pathForResource:sound ofType:type];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesAddSystemSoundCompletion(soundID, NULL, NULL, playSoundFinished, data);
AudioServicesPlaySystemSound(soundID);
and my playSoundFinished method:
static void playSoundFinished(SystemSoundID soundID, void *data) {
NSArray *data_ = (NSArray *)data;
id obj = [data_ objectAtIndex:0];
SEL method = NSSelectorFromString([data_ objectAtIndex:1]);
[obj performSelector:method];
}
The documentation stats that the last parameter must be a void*
and that it's the data to work in callback method, but how can I use the NSArray that I pass as argument? I'm new in C and Objective-C, so sorry if it's a dumb question. Casting works fine, but when I try to access the first position, a bad execution occurs. I really didn't understand why void* type. What that means?
In this other post the guy pass a UIButton without any casting and that idea didn't work for me too.
Can you help me?
Thanks in advance.