title: Objective C Updating Objects In Array
body: <p>When storing an object in an NSMutableArray, I am having trouble updating the properties of an object, such as the background color or the "hidden" property of a UIView.</p>
  
  <pre><code>NSMutableArray *myArray;
  
  UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
  myView.backgroundColor = [UIColor blueColor];
  [self.view addSubview:myView];
  myArray[0] = myView;    
  
  //myArray[0].backgroundColor = [UIColor redColor];
  ((UIView *)myArray[0]).backgroundColor = [UIColor redColor];
  </code></pre>
  
  <p>My first attempt is commented out, it doesn't compile because myArray[0] returns type "id" so the compiler doesn't recognize the backgroundColor property.</p>
  
  <p>For my second attempt, I casted it into a UIView, so it recognizes the backgroundColor property, but the code doesn't work (the background is still blue).</p>
  
  <p>Is casting to a UIView creating a copy of my view, and therefore not updating the view I intended to update? How can I get this to work using an array of UIViews?</p>