Dok-tips for Foundation class NSMutableAttributedString

Mutable - even volatile! - so, make NSAttributedString copies of it if you need it to stick around

Effectively has a "dictionary" for each character - not actually, but effectively. You get this dictionary by calling:

- (NSDictionary *)attributesAtIndex:(NSUInteger)index effectiveRange:(NSRangePointer)range;

Note: it does NOT inherit from NSString. You can however convert an NSAtributedString into an NSString by calling its string method as in

NSRange r = [[attributedString string] rangeOfString:substring];

Where the range is returned via the NSRangePointer variable to indicate how far from the index the attributes are identical

Setting attributes replaces all the attributes for the range, Adding only overrides the specific attribute, Removing an attribute allows it to go back to its default

Besides being able to modify characters using append, insert, delete, or replace, you can also call - (NSMutableString *)mutableString to get a mutable string that can be modified - its magic


New for iOS 6

List of all foundation classes