Reputation: 2200
for (int i=0 ; i<=[secondSplitArrayValue count]; i++)
{
if (![[secondSplitArrayValue objectAtIndex:i] isEqualToString:@"NULL"] ||
![[splitArrayValue objectAtIndex:i] isEqualToString:@"Error"]
{
[secondSplitArrayValue removeObjectAtIndex:i];
}
}
I am trying to remove value of array at particular index where string is NOT EQUAL (!=) to NULL or Error. But in debugging time object is removed where NULL and Error present but I want to remove object where Null and Error not present.
Upvotes: 4
Views: 10432
Reputation: 34265
for (int i=0 ; i<=[secondSplitArrayValue count]; i++)
{
if (!([[secondSplitArrayValue objectAtIndex:i] isEqualToString:@"NULL"]) ||
!([[splitArrayValue objectAtIndex:i] isEqualToString:@"Error"]))
{
[secondSplitArrayValue removeObjectAtIndex:i];
}
}
Upvotes: 0
Reputation: 10344
Try this.
for (int i=0 ; i<=[secondSplitArrayValue count]; i++)
{
if (([[secondSplitArrayValue objectAtIndex:i] isEqualToString:@"NULL"] == FALSE) ||
([[splitArrayValue objectAtIndex:i] isEqualToString:@"Error"] == FALSE))
{
[secondSplitArrayValue removeObjectAtIndex:i];
}
}
Upvotes: 0
Reputation: 26390
for (int i=0 ; i<=[secondSplitArrayValue count]; i++)
{
if (!([[secondSplitArrayValue objectAtIndex:i] isEqualToString:@"NULL"] ||
[[splitArrayValue objectAtIndex:i] isEqualToString:@"Error"] ))
{
[secondSplitArrayValue removeObjectAtIndex:i];
}
}
See if this helps
Upvotes: 0
Reputation: 2953
You're probably looking for this I think:
for (int i=0 ; i<=[secondSplitArrayValue count]; i++)
{
if (!([[secondSplitArrayValue objectAtIndex:i] isEqualToString:@"NULL"] ||
[[splitArrayValue objectAtIndex:i] isEqualToString:@"Error"])
{
[secondSplitArrayValue removeObjectAtIndex:i];
}
}
This way you inverse the boolean operation only after you have completed the check for both cases, and the OR operation of both of the resulting checks.
Upvotes: 9