Class: NSMutableAttributedString
- Inherits:
-
NSAttributedString
- Object
- NSObject
- NSAttributedString
- NSMutableAttributedString
Overview
NSMutableAttributedString declares the programmatic interface to objects that manage mutable attributed strings. You can add and remove characters (raw strings) and attributes separately or together as attributed strings. See the class description for NSAttributedString for more information about attributed strings.
Instance Method Summary (collapse)
-
- addAttribute:value:range:
Adds an attribute with the given name and value to the characters in the specified range.
-
- addAttributes:range:
Adds the given collection of attributes to the characters in the specified range.
-
- appendAttributedString:
Adds the characters and attributes of a given attributed string to the end of the receiver.
-
- beginEditing
Overridden by subclasses to buffer or optimize a series of changes to the receiver’s characters or attributes, until it receives a matching endEditing message, upon which it can consolidate changes and notify any observers that it has changed.
-
- deleteCharactersInRange:
Deletes the characters in the given range along with their associated attributes.
-
- endEditing
Overridden by subclasses to consolidate changes made since a previous beginEditing message and to notify any observers of the changes.
-
- insertAttributedString:atIndex:
Inserts the characters and attributes of the given attributed string into the receiver at the given index.
-
- mutableString
Returns the character contents of the receiver as an NSMutableString object.
-
- removeAttribute:range:
Removes the named attribute from the characters in the specified range.
-
- replaceCharactersInRange:withAttributedString:
Replaces the characters and attributes in a given range with the characters and attributes of the given attributed string.
-
- replaceCharactersInRange:withString:
Replaces the characters in the given range with the characters of the given string.
-
- setAttributedString:
Replaces the receiver’s entire contents with the characters and attributes of the given attributed string.
-
- setAttributes:range:
Sets the attributes for the characters in the specified range to the specified attributes.
Methods inherited from NSAttributedString
#attribute:atIndex:effectiveRange:, #attribute:atIndex:longestEffectiveRange:inRange:, #attributedSubstringFromRange:, #attributesAtIndex:effectiveRange:, #attributesAtIndex:longestEffectiveRange:inRange:, #enumerateAttribute:inRange:options:usingBlock:, #enumerateAttributesInRange:options:usingBlock:, #initWithAttributedString:, #initWithString:, #initWithString:attributes:, #isEqualToAttributedString:, #length, #string
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Method Details
- (Object) addAttribute(name, value:value, range:aRange)
Adds an attribute with the given name and value to the characters in the specified range.
You may assign any name/value pair you wish to a range of characters, in addition to the standard attributes described in the “Constants” section of NSAttributedString Additions. Raises an NSInvalidArgumentException if name or value is nil and an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
- (Object) addAttributes(attributes, range:aRange)
Adds the given collection of attributes to the characters in the specified range.
You may assign any name/value pair you wish to a range of characters, in addition to the standard attributes described in the “Constants” section of NSAttributedString Additions. Raises an NSInvalidArgumentException if attributes is nil and an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
- (Object) appendAttributedString(attributedString)
Adds the characters and attributes of a given attributed string to the end of the receiver.
- (Object) beginEditing
Overridden by subclasses to buffer or optimize a series of changes to the receiver’s characters or attributes, until it receives a matching endEditing message, upon which it can consolidate changes and notify any observers that it has changed.
You can nest pairs of beginEditing and endEditing messages.
- (Object) deleteCharactersInRange(aRange)
Deletes the characters in the given range along with their associated attributes.
Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
- (Object) endEditing
Overridden by subclasses to consolidate changes made since a previous beginEditing message and to notify any observers of the changes.
The NSMutableAttributedString implementation does nothing. NSTextStorage, for example, overrides this method to invoke fixAttributesInRange: and to inform its NSLayoutManager objects that they need to re-lay the text.
- (Object) insertAttributedString(attributedString, atIndex:index)
Inserts the characters and attributes of the given attributed string into the receiver at the given index. The new characters and attributes begin at the given index and the existing characters and attributes from the index to the end of the receiver are shifted by the length of the attributed string. Raises an NSRangeException if index lies beyond the end of the receiver’s characters.
- (String) mutableString
Returns the character contents of the receiver as an NSMutableString object.
The receiver tracks changes to this string and keeps its attribute mappings up to date.
- (Object) removeAttribute(name, range:aRange)
Removes the named attribute from the characters in the specified range.
Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
- (Object) replaceCharactersInRange(aRange, withAttributedString:attributedString)
Replaces the characters and attributes in a given range with the characters and attributes of the given attributed string.
Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
- (Object) replaceCharactersInRange(aRange, withString:aString)
Replaces the characters in the given range with the characters of the given string. The new characters inherit the attributes of the first replaced character from aRange. Where the length of aRange is 0, the new characters inherit the attributes of the character preceding aRange if it has any, otherwise of the character following aRange.Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
- (Object) setAttributedString(attributedString)
Replaces the receiver’s entire contents with the characters and attributes of the given attributed string.
- (Object) setAttributes(attributes, range:aRange)
Sets the attributes for the characters in the specified range to the specified attributes.
These new attributes replace any attributes previously associated with the characters in aRange. Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.To set attributes for a zero-length NSMutableAttributedString displayed in a text view, use the NSTextView method setTypingAttributes:.