setAnimationDidStopSelectorについて教えてください(iPhone SDK)
質問者:*********
以下のようなコードを組んでいるのですが、setAnimationDidStopSelectorで指定したendDropPartメソッドの中で、どうやってアニメーションさせるオブジェクトを指定するか悩んでいます。iPhone SDKは初心者です。どなたかご教授いただけないでしょうか?

-(void)endDropPart{
  /*
  [下のメソッドのrrecieverが指すボタン setAlpha:1.0f];
  */
  NSLog(@"endAnim");
}

- (void)DropPart:(UIButton *)reciever {

  [player play];

  CGFloat y = [reciever center].y;

  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:0.5f];
  [UIView setAnimationDelegate:self];
  [UIView setAnimationDidStopSelector:@selector(endDropPart)];

  [reciever setCenter:CGPointMake([reciever center].x, y+150)];
  [reciever setAlpha:0.0f];

  [UIView commitAnimations];

}

質問番号:6208585

回答

回答者:*********

> [UIView setAnimationDidStopSelector:@selector(endDropPart)];

アニメーション終了時に呼び出されるDelegateは、
「- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context」
にしたほうがいい(should be)と、UIViewのリファレンスに書かれています。それはご存じですよね?
この引数のcontextは、
「+ (void)beginAnimations:(NSString *)animationID context:(void *)context」の引数contextを引き継ぎます。
contextに
「(UIButton *)reciever」(receiverという命名には、強い違和感を覚えます。ふつうはsenderとしますね)
を代入することで、ボタンのポインタを終了時のDelegateに渡せます。
なお、contextは、(void *)とあるように、ポインタ値のみで、クラスがなんであるかは受け渡さないので、すこし手間をかける必要があります。