Hi,
I developed category for UIImageView:
And then create 3 images. Set ONLY one setVal with "123". And add to NSArray
So , I get "123" value for all images. WHY? What is wrong???
Thanks
I developed category for UIImageView:
PHP:
- (NSInteger) val
{
return val;
}
- (void) setVal: (NSInteger)myValue
{
val = myValue
}
PHP:
NSMutableArray *myArray = [[NSMutableArray alloc]init];
UIImageView *view1 = [[UIImageView alloc] initWithFrame: CGRectMake(0.0, 0.0, 10, 10)];
[view1 setVal: 123];
[myArray addObject: view1];
UIImageView *view2 = [[UIImageView alloc] initWithFrame: CGRectMake(10.0, 0.0, 10, 10)];
[myArray addObject: view2];
UIImageView *view3 = [[UIImageView alloc] initWithFrame: CGRectMake(20.0, 0.0, 10, 10)];
[myArray addObject: view3];
for(int a=0; a<[myArray count]; a++)
{
UIImageview *view = [myArray objectAtIndex: a];
NSLog(@"Object: %d : %d", a, [view val]);
}
Thanks