Sunday, 15 July 2012

objective c - Use for-loop instead of repeating -



objective c - Use for-loop instead of repeating -

xcode noob here. can please guide me how create list below done in for-loops? if possible? have working such lists takes much time , can cause error due repetition.

_monkey1.center = cgpointmake(_monkey1.center.x, _monkey1.center.y); _monkey2.center = cgpointmake(_monkey2.center.x, _monkey2.center.y); _monkey3.center = cgpointmake(_monkey3.center.x, _monkey3.center.y); _monkey4.center = cgpointmake(_monkey4.center.x, _monkey4.center.y); _monkey5.center = cgpointmake(_monkey5.center.x, _monkey5.center.y); etc.

i have started with:

for (int k = 1; k < 20; k++){ // prep? [[_monkeys objectatindex: k] setcenter: .... }

is there possible way this? other suggestions appreciated.

monkeys uiimageviews. thanks.

nsarray *monkies = @[ _monkey1, _monkey2, _monkey3, _monkey4, _monkey5 ]; (uiimageview *monkey in monkies) { monkey.center = cgpointmake(monkey.center.x, monkey.center.y); }

(note, i've assumed these objects of type monkey, might incorrect).

objective-c for-loop

No comments:

Post a Comment