0
我創建一個屬性字符串並有條件地應用刪除線。下面的代碼:NSAttributedString錯誤。它附加屬性字典的描述
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;
}
所以字典的描述被附加到屬性串。任何想法爲什麼?