@
austinchou0126 yes cs193p
刚才试了下,通过在controller里面建一个类方法,用来转换string到 attributestring
然后遇到一个比较奇怪的问题
int index1 = 0;
NSRange range1 = NSMakeRange(index1, 1);
NSString* str1 = @"♣︎";
NSString* substring1 = [str1 substringWithRange: range1];
NSString* substring2 = [str1 substringFromIndex:index1];
NSLog(@"*%@%@* %d", substring1, @"♣︎", [substring1 isEqualToString:@"♣︎"]);
NSLog(@"*%@%@* %d", substring2, @"♣︎", [substring2 isEqualToString:@"♣︎"]);
的结果是:
2014-02-09 04:17:57.856 CartGAme[24495:907] *♣♣︎* 0
2014-02-09 04:17:57.858 CartGAme[24495:907] *♣︎♣︎* 1