For Loop Question?
Posted
by NextRev
on Stack Overflow
See other posts from Stack Overflow
or by NextRev
Published on 2010-03-27T02:05:05Z
Indexed on
2010/03/27
2:13 UTC
Read the original article
Hit count: 415
I'm programming an app for the iPhone. I'm not very good with loops just yet. How do I shorten this code into a for loop?
if(CGRectContainsRect([space1 frame], [box frame])){
space1.image = [UIImage imageNamed:@"box.png"];
}
else if(CGRectContainsRect([space2 frame], [box frame])){
space2.image = [UIImage imageNamed:@"box.png"];
}
else if(CGRectContainsRect([space3 frame], [box frame])){
space3.image = [UIImage imageNamed:@"box.png"];
}
else if(CGRectContainsRect([space4 frame], [box frame])){
space4.image = [UIImage imageNamed:@"box.png"];
}
else if(CGRectContainsRect([space5 frame], [box frame])){
space5.image = [UIImage imageNamed:@"box.png"];
}
© Stack Overflow or respective owner