title: Parse UIButton into method in Objective-C
body: <p>I have some methods that interact with the UIButtons in my view controller, with a lot of repetitive code. Here's an example of one of those methods: </p>
  
  <pre><code>-(void)spinButtons {
  CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
  fullRotation.fromValue = [NSNumber numberWithFloat:0];
  fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
  fullRotation.duration = 3;
  fullRotation.repeatCount = 0;
  
  
  [_button1.layer addAnimation:fullRotation forKey:@"360"];
  [_button2.layer addAnimation:fullRotation forKey:@"360"];
  [_button3.layer addAnimation:fullRotation forKey:@"360"];
  [_button4.layer addAnimation:fullRotation forKey:@"360"];
  [_button5.layer addAnimation:fullRotation forKey:@"360"];
  [_button6.layer addAnimation:fullRotation forKey:@"360"];
  </code></pre>
  
  <p>}</p>
  
  <p>Is there a way how I can store the name of the buttons in an NSdictionary, list etc so i can turn the above into this:</p>
  
  <pre><code>-(void)spinButtons:(UIButton *)button {
  CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
  fullRotation.fromValue = [NSNumber numberWithFloat:0];
  fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
  fullRotation.duration = 3;
  fullRotation.repeatCount = 0;
  
  [button.layer addAnimation:fullRotation forKey:@"360"];
  </code></pre>
  
  <p>}</p>
  
  <p>I Hope this makes sense!</p>