[attributedString enumerateAttributesInRange:range options:NSAttributedStringEnumerationReverse usingBlock:
^(NSDictionary *attributes, NSRange range, BOOL *stop) {
NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
[mutableAttributes setObject:[NSNumber numberWithInt:1] forKey:@"NSUnderline"];
attributes = mutableAttributes;
}];
Run Code Online (Sandbox Code Playgroud)
我试图循环所有属性并添加NSUnderline给他们.在调试时,似乎NSUnderline被添加到字典中,但是当我第二次循环时它们被删除.我在更新NSDictionaries时做错了什么?