Eduard
Eduard

Reputation: 536

How can I change center of a view, which is stored in NSArray?

I am trying to access property of UIView stored in NSArray but getting "Property 'center' not found on object of type'id'" message. What can i do to avoid this?

[_toggles objectAtIndex:i-1].center = CGPointMake(i * (toogleSize + freeSpace) - 24, 48);

Upvotes: 0

Views: 32

Answers (1)

godel9
godel9

Reputation: 7390

You can cast the result of _toggles[i-1] to a UIView* and then access the center property:

((UIView*)_toggles[i-1]).center = CGPointMake(...);

You just have to remember the parentheses in the right place to make sure you cast _toggles[i-1] before you access center.

Upvotes: 1

Related Questions