can I do this?
[array enumerateUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
if (idx > 1)
{
NSUInteger previous1 = [array objectAtIndex: idx - 1].value;
NSUInteger previous2 = [array objectAtIndex: idx - 2].value;
obj.value = previous1 + previous2;
}
}];
is it safe to do this? I am not adding/removing objects in array(or mutable array) inside enumeration block, I am just getting/changing value of object in other idx.
Thanks
That is OK, except that you have to cast your objects to the right type before you can use the dot syntax to get to the value property.