Я не совсем уверен, что это то, что вы хотите, но я думаю, что это так.
Чтобы сократить строку до одного числа, используйте эту функцию.
+(NSString*) removeDuplicateNumbersFromString:(NSString*)first{
//if first is "1112222334445" the return value of this function would be "12345"
NSString *end = [NSString stringWithString:@""]; //the return string
char last; //will track changes in numbers
for (int i = 0; i < [first length]; i++) {
char charAtIndex = [first characterAtIndex:i];
if (last != charAtIndex) {
//if the last character is different than the current character
//set the current character as last, and add that character to the return string
last = charAtIndex;
end = [end stringByAppendingFormat:@"%c",last];
}
}
NSLog(@"First:%@, End:%@",first,end); //prints out the start/end strings
return end;
}