Q:

can't access invisible cells in uitableview

i have a table view with a switch in each cell. i want to hide the switches in edit mode. I done with the following code
-(void)displaySwitch:(BOOL)status   {

    int count  = [self.tblView numberOfRowsInSection:0];
    int i;
    for (i = 0; i<count; i++) {
        UITableViewCell *eachCell = [self.tblView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
        //NSLog(@"%@",eachCell);
        NSArray *subViews = [eachCell.contentView subviews];
        for (UISwitch *eachObject in subViews) {
            if ([eachObject isKindOfClass:[UISwitch class]]) {

                CATransition *animation = [CATransition animation];
                animation.type = kCATransitionFade;
                animation.subtype = kCATransitionFromLeft;
                animation.duration = 1.4;
                animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
                [eachObject.layer addAnimation:animation forKey:kCATransition];
                eachObject.hidden = status;

            }

        }

    }

}

It works fine for all the visible cells. But i cant't access any invisible cells with this code. cell returns nil. So the switches in invisible cell doesn't hide. How can i overcome this issue. please help me
One more thing, animation not working here. But it is a secondary issue.

A:

Modified your code only have a look
-(void)displaySwitch:(BOOL)status onCell:(UITableViewCell*)cell   {

    NSArray *subViews = [cell.contentView subviews];
    for (UISwitch *eachObject in subViews) {
        if ([eachObject isKindOfClass:[UISwitch class]]) {

            CATransition *animation = [CATransition animation];
            animation.type = kCATransitionFade;
            animation.subtype = kCATransitionFromLeft;
            animation.duration = 1.4;
            animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            [eachObject.layer addAnimation:animation forKey:kCATransition];
            eachObject.hidden = status;

        }
   }
}

Then call this function 
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(cell == nil){

        //Cell initialization

    }

    [self displaySwitch:self.editing onCell:cell];
}

