我正在创建一个属性字符串并有条件地应用删除线。这是代码:
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
if (needsStrikeThrough) {
[attributes setValue:[NSNumber numberWithInt:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
} else {
[attributes setValue:[NSNumber numberWithInt:NSUnderlineStyleNone] forKey:NSStrikethroughStyleAttributeName];
}
NSAttributedString *attString = [[NSAttributedString alloc] initWithString:participant.firstName attributes:attributes];
NSLog(@"attString= %@", attString);
NSLog(@"[attributes description]= %@", [attributes description]);
控制台中的输出是这样的:
attributedParticipantName= Belinda{
NSStrikethrough = 0;
}
[attributes description]= {
NSStrikethrough = 0;
}
所以字典的描述被附加到属性字符串中。知道为什么吗?