Post your code. It sounds like you're adding the same instance to the array three times; adding it to the array doesn't make a copy, so of course you get the same result three times.
Code:
//how to get three of the same object
MyClass *myObject = [[MyClass alloc] init]];
for(int i=0; i<3; i++){
myObject.property = i;
[myArray addObject:myObject];
}
[myObject release];
Now the array contains the same object three times, and "property" is set to "2" for that object.
It sounds like you want this:
Code:
//how to get three different objects
for(int i=0; i<3; i++){
MyClass *myObject = [[MyClass alloc] init]];
myObject.property = i;
[myArray addObject:myObject];
[myObject release];
}
Now you have three objects with three different properties.
EXTRA CREDIT: If you want the objects to be *nearly* identical with most of the properties the same you could write a copyWithZone method for the class, create one with the base properties set, and then [myObject copy] it before setting the different props and adding to the array. Just don't forget to release it; you own objects that are returned by a correctly written [ copy] method.