3

Is it OK to use UITableViewCellDeleteConfirmationControl this way:

- (void)layoutSubviews {
    [super layoutSubviews];

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:0.0f];

    for (UIView *subview in self.subviews) {
        if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) { 
        CGRect newFrame = subview.frame;
        newFrame.origin.x = 200;
        subview.frame = newFrame;
        }
        else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {             
            CGRect newFrame = subview.frame;
            newFrame.origin.x = 100;
            subview.frame = newFrame;
        }
        else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellReorderControl"]) {             
        CGRect newFrame = subview.frame;
        newFrame.origin.x = 200;
        subview.frame = newFrame;
       }
   }
   [UIView commitAnimations];
}

Even though UITableViewCellDeleteConfirmationControl is not a public class?

oridahan
  • 574
  • 1
  • 7
  • 20

2 Answers2

0

Since you're comparing string equality you're not exposing any private API's and therefore should be eligible for AppStore submission.

I've been successfully able to use this equality check in my own app that's made it to the AppStore.

0

First, a class is not a string. You should use NSStringFromClass([subview class]) to get a string representation of the class name.

Second, having the entire class name as a string literal is a big risk, and you should not have it so obvious. For instance, you could test if the name contains a portion of the name you are looking for: [className rangeOfSubstring:@"DeleteConfirmation"].location != NSNotFound.

Third, the reason this is not exposed is because it is private implementation of tableview cells. A good example why you shouldn't is on iOS7, the entire implementation of cells has been changed completely. The classes you mention in your example are no longer used.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195