Hello guys,
what is the problem with this code?
what is the problem with this code?
Code:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *sentence=[NSString stringWithString:@"i want to filter this sentence by stoplist array for my program"];
NSArray *stopList=[[NSArray alloc]initWithObjects:@"an,@and,@by,@for,@from,@of,@the,@to,@with",nil];
NSArray *query = [sentence componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSMutableArray *finalsentence=[NSMutableArray array];
for(NSString *q in query){
if ([stopList containsObject:q]== YES) {
[finalsentence addObject:q];
}
}
NSLog(@"%@",finalsentence);
[pool drain];
return 0;
}