NSString *str = @"z😀a😃";
for(int i=0; i<str.length; i++){
NSString *s = [str substringWithRange:NSMakeRange(i, 1)];
NSLog(@"%@",s);
}
NSRange range;
for(int i=0; i<str.length; i+=range.length){
range = [str rangeOfComposedCharacterSequenceAtIndex:i];
NSString *s = [str substringWithRange:range]; //attributedSubstringFromRange:range];
NSLog(@"%@",s);
}
NSLog(@"%ld",str.length);
网友评论