views:

37

answers:

1

In Class Foo I have a retained property of an NSArray which holds UIViews (which have backgroundColor properties)

In an instance of class Bar I set the NSArray to an array of views, and then set a views background color:

[viewOne setBackgroundColor:[UIColor blueColor]];
NSArray *tempArray = [[NSArray alloc] initWithObjects:viewOne, viewTwo, nil];
[iFoo setArray:tempArray];
[tempArray release];
[viewOne setBackgroundColor:[UIColor redColor]];
[iFoo doSomething];

then in iFoo, the method doSomething is:

NSLog([((UIView*)[self.array objectAtIndex:0]).backgroundColor description]);

which returns the blue color. How can I make it so it returns the red color that was set after the view was added to the view? I think it's something to do with pointers (which I understand, well I did but now I can't remember exactly)?

+2  A: 

Probably just a typo in your code: The index of viewOne, of which you set the red color, is 0 not 1

nesium
Not probably, definitely. In tempArray, viewOne is at index 0.
bbum
No sorry that was just a type on here.
Jonathan