EDIT: Updated code to better reflect my problem
this code returns 9 strings to badDestination1
NSMutableArray* goodDestination1 = [NSMutableArray array];
NSMutableArray* badDestination1 = [NSMutableArray array];
NSMutableArray* badDestination2 = [NSMutableArray array];
for (NSString* item in sourceArray)
{
if ([item rangeOfString:@"<b>"].locatio开发者_Python百科n != NSNotFound)
[goodDestination1 addObject:item];
else {
[badDestination1 addObject:item];
//[badDestination2 addObject:@"Title"];
}
}
This code returns 1 value to badDestination2
for (NSString* item in sourceArray)
{
if ([item rangeOfString:@"<b>"].location != NSNotFound)
[goodDestination1 addObject:item];
else {
//[badDestination1 addObject:item];
[badDestination2 addObject:@"String"];
}
}
anyone know whats going on? Seems like the "String" might be getting rewritten in the same location on the array maybe?
Looks like you're missing the braces {}
after the else
.
else {
[arrayDestinationBad1 addObject:item];
[arrayDestinationBad2 addObject:@"String"];
}
精彩评论