iOS 字符串去除相同元素
/**
去除字符串中相同的元素只保留一个
如:1121334466 - > 12346
**/
-(NSString *)removeStrxtys:(NSString *)origStr{
NSString *temp = nil;
NSMutableArray *arr_0 = [NSMutableArray new];
for(int i =0; i < [origStr length]; i++)
{
temp = [origStr substringWithRange:NSMakeRange(i, 1)];
BOOL isbool = [arr_0 containsObject:temp];
if (!isbool) {
[arr_0 addObject:temp];
}
}
NSString *result = [arr_0 componentsJoinedByString:@""];
return result;
}
本文标题:iOS 字符串去除相同元素
本文链接:https://www.haomeiwen.com/subject/hkwsmqtx.html
网友评论