views:

79

answers:

3

hi,
how can i implement an NSArray in this method (instead of just defining each one of the objects).

code:

- (void) fadeOutShuffleAnimation
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration: 0.8];
    [UIView setAnimationDelegate:self];
    juw1.alpha = 0.0;
    juw2.alpha = 0.0;
    juw3.alpha = 0.0;
    juw4.alpha = 0.0;
    ...
    [UIView commitAnimations];
}
+2  A: 

if juw* are uiviews (or uiview subclasses) you can assign them unique tag property and loop through them like:

for (loop tag condition){
   [parentView viewWithTag: tag].alpha = 0;
}

So actually after you create your items and add to parentView as subviews you might not need to store items as you can always get them using their tags.

Vladimir
+1  A: 

Maybe take all objects from view.subviews and set alpha to 0

example:

for(UIView *v in self.view.subviews) {
   if([v isKindOfObject:[UIImageView class]] ) {
      v.alpha = 0;
   }
}
sakrist
+1  A: 
// initialize _juwArray array
NSMutableArray *_juwArray = [NSMutableArray arrayWithCapacity:size];
for (NSInteger index = 0; index < size; index++) {
    // instantiate _juw instance and add it to _juwArray
    // assuming conformation to NSCopying/NSMutableCopying protocols
    // or that Juw is a subclass of UIView  
    [_juwArray addObject:_juw];
}

// set alpha values
for (NSInteger index = 0; index < size; index++) {
    [((Juw *)[_juwArray objectAtIndex:index]) setAlpha:0.0];
}
Alex Reynolds