i have a UIImageView object that i’m trying to get x coordinate of. I do this with code below
endingPoint.x = myObject.center.x;
Now, how can i do this if i have the same UIImageView inside of an array that i’m trying to loop through and get each object’s x coordinate, some thing like below?
endingPoint.x = [posArray objectAtIndex:i].center.x;
I know it’s a newbie question but i’m just starting with iOS.
You’re very close. objectAtIndex: however, returns objects of type id (a generic pointer to anything), so you may not call .center (property) on it.
You must send it a message using the brackets symbols like this:
or cast the value to (UIImageView *) first: