Skip to main content
deleted 9 characters in body
Source Link
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:@""];
    }
    // -----------

  }
}

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:@""];
    }
    // -----------

  }
}

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 || [self isCurrentPosition:i]) ) {
        [self replaceObjectAtIndex:i withObject:@""];
    }
    // -----------

  }
}
Source Link
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:@""];
    }
    // -----------

  }
}