Q:

How to remove common letters in two Strings in iOS SDK?

How can i remove common letters in two strings and generate a new string using remaining unique letters ?
for example:
String 1= Optimus Prime,
String 2= Deja Thoras,

new string should be: Djaha

A:

Here's a way that avoids the nitty gritty of character enumeration:
NSString *string1 = @"Deja Thoras";
NSString *string2 = @"Optimus Prime";

NSCharacterSet *filterSet = [NSCharacterSet characterSetWithCharactersInString:string2];
NSString *filteredString = [[string1 componentsSeparatedByCharactersInSet:filterSet] componentsJoinedByString:@""];

A:

Just enumerate through the characters in the string and delete matching ranges. Be sure to search 'caselessly' (ie the difference between uppercase and lowercase letters is irrelevant). The following snippet logs "Djaha", as the opening post expects.
NSString *firstString = @"Deja Thoras";
NSString *secondString = @"Optimus Prime";

NSMutableString *outputString = [NSMutableString stringWithString:firstString];

[outputString enumerateSubstringsInRange:NSMakeRange(0, firstString.length) options:NSStringEnumerationByComposedCharacterSequences 
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
    if ([secondString rangeOfString:substring options:NSCaseInsensitiveSearch].location != NSNotFound) {
        [outputString deleteCharactersInRange:substringRange];
    }
}];

NSLog(@"%@", outputString);

If this is a common operation, I would place the code into a category, with a method name like stringByRemovingMatchingCharactersInString:

