On Jul 2, 2009, at 5:36 PM, Agha Khan wrote:

I have saved some objects inside GameArray (type NSMutableArray) and I would like to change of content of an object inside that array.

GameObj is type of UIView so it has a frame.

GameObj* p = [GameArray objectAtIndex:0];
p.frame = frame;

This works, but this is not changing the content inside the GameArray.

What do you mean it "is not changing the content inside the GameArray"? By what means are you detecting this?

It is most definitely the case that the above code snippet is changing the frame of the object at index 0 of the array. An array contains references to objects. It doesn't really contain the objects themselves. So, the pointer 'p' in your snippet is a reference to the same object that the array has a reference to. There's no way for the change you make through 'p' to not affect the object referred to by the array, since they are the same object.

If you think it is not changing the object in the array, then you are confused or mistaken.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to