Edit:
I've just noticed that in initSoundResources, you are alloc'ing and init'ing an APlayer object, but then assigning a float to the pointer straight afterwards. I'm pretty sure this isn't what you're intending.
Try this:
- (void) startAnimation {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(playSound)];
CGPoint destination = CGPointMake(152,20);
pink.center = destination;
[UIView commitAnimations];
}
- (void) initSoundResources {
soundPink = [[APlayer alloc] initWithFile:@"pink" type:@"mp3"];
soundPink = 0.4;
}
- (void) playSound {
//assuming initSoundResources is called at some point before this...
[soundPink play];
}
The idea here is that UIView animations are asynchronous. If the animation is set to be 0.8 seconds long, that doesn't mean the code will take 0.8 seconds to run.
What I mean is that the code straight after the UIView animations code gets called effectively instantly after the animation code. In this case the sound is going to play (probably) before the animation even starts.
I can't imagine why it would pause or freeze, but using this method should work.
In my code, I have taken the assumption that the initSoundResources method is called at some point before trying to play the sound.
If the soundPink pointer is not initialised to nil or a valid sound instance, then sending it the play message may cause a crash.