Do it in three steps
1) NSArray *items = [theString componentsSeparatedByString:@","];
2) remove duplicate element from array
NSArray* array = [NSArray arrayWithObjects:@"test1", @"test2", @"test1", @"test2",@"test4", nil];
NSArray* filteredArray = [[NSArray alloc] init];
NSSet *set= [NSOrderedSet orderedSetWithArray:array];
filteredArray = [set allObjects];
3) Concate String from array
NSString *myString = [myArray componentsJoinedByString:@","];