this is my first post here!
HowHow can iI optimize the ifif
condition onin this snippet?
The only one difference is && [self isCurrentPosition:i]
.
How How can madeI make it on a single ifif
, including the condition val
?
Note: self
is a category of NSArray
.
- (void) cleanTextfieldExcluding:(int)current checkPosition:(BOOL)val {
for ( int i=0; i<[self count]; i++ ) {
// -----------
if ( val ) { // this IF block is very bad
if ( i != current && [self isCurrentPosition:i] )
[self replaceObjectAtIndex:i withObject:@""];
} else {
if ( i != current )
[self replaceObjectAtIndex:i withObject:@""];
}
// -----------
}
}
Note: self
is a category of NSArray
.
thanks.