Skip to main content
1 of 2
resgh
  • 214
  • 1
  • 7

It seems that the code in if will be executed only if i != current and val && [self isCurrentPosition:i] or !val, so you could merge all the ifs into one:

- (void) cleanTextfieldExcluding:(int)current checkPosition:(BOOL)val {
  for ( int i=0; i<[self count]; i++ ) {

    // -----------
    if ( (i != current) && (!val || (val && [self isCurrentPosition:i])) ) {
        [self replaceObjectAtIndex:i withObject:@""];
    }
    // -----------

  }
}
resgh
  • 214
  • 1
  • 7