0
我是新来的编程和目标C,抱歉,我不得不问这个基本问题。我无法弄清楚下面的代码行。为什么评估属性时我需要使用&符号作为范围?但是当我再次调用属性时不使用它?是因为第一个是一个setter,第二个是getter?访问属性
感谢您的建议!
-(NSAttributedString*)characterWithAttribute: (NSString*)attributeName{
NSMutableAttributedString* characters = [[NSMutableAttributedString alloc]init];
int index = 0;
while(index < [self.textToAnalyze length]){
NSRange range;
id value = [self.textToAnalyze attribute:attributeName atIndex:index effectiveRange:&range];
if(value){
[characters appendAttributedString:[self.textToAnalyze attributedSubstringFromRange:range]];
index = (int)range.location + (int)range.length;
}
else{
index++;
}
}
return characters;
}
感谢菲利普感谢你的解释和链接 –