Platforms to show: All Mac Windows Linux Cross-Platform

Back to CFMutableAttributedStringMBS class.

CFMutableAttributedStringMBS.AsNSMutableAttributedString as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new NSMutableAttributedStringMBS object pointing to same mutable attributed string.

For passing to functions which need a NSMutableAttributedStringMBS.

CFMutableAttributedStringMBS.BeginEditing

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Marks the beginning of a series of changes.

In cases where attributed string might do a bunch of work to assure self-consistency, BeginEditing/EndEditing allow disabling that to allow deferring and coalescing any work. It's a good idea to call these around a set of related mutation calls which don't require the string to be in consistent state in between. These calls can be nested.

CFMutableAttributedStringMBS.Constructor(maxLength as Integer = 0)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a mutable empty attributed string.

maxLength, if not 0, is a hard bound on the length of the attributed string; exceeding this size limit during any editing operation is a programming error. If 0, there is no limit on the length.

See also:

CFMutableAttributedStringMBS.Constructor(str as CFAttributedStringMBS, range as CFRangeMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a sub-attributed string from the specified range.

str: The attributed string to copy.
range: The range of the attributed string to copy. range must not exceed the bounds of Str.

Returns a new attributed string whose string and attributes are copied from the specified range of the supplied attributed string. Raises OutOfMemory exception if there was a problem copying the object. Ownership follows the Create Rule.

See also:

CFMutableAttributedStringMBS.Constructor(str as CFStringMBS, attributeDictionary as CFDictionaryMBS = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an attributed string with specified string and attributes.

str: A string that specifies the characters to use in the new attributed string. This value is copied.
attributeDictionary: A dictionary that contains the attributes to apply to the new attributed string. This value is copied.

Returns an attributed string that contains the characters from str and the attributes specified by attributes. Raises OutOfMemory exception if there was a problem in creating the attributed string.

Note that both the string and the attributes dictionary are copied. The specified attributes are applied to the whole string. If you want to apply different attributes to different ranges of the string, you should use a mutable attributed string.

See also:

CFMutableAttributedStringMBS.EndEditing

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Marks the end of a series of changes.

In cases where attributed string might do a bunch of work to assure self-consistency, BeginEditing/EndEditing allow disabling that to allow deferring and coalescing any work. It's a good idea to call these around a set of related mutation calls which don't require the string to be in consistent state in between. These calls can be nested.

CFMutableAttributedStringMBS.MutableString as CFMutableStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Gets the string for the attributed string as a mutable string, allowing editing the character contents of the string as if it were an CFMutableString.

Attributes corresponding to the edited range are appropriately modified. If, as a result of the edit, new characters are introduced into the string, they inherit the attributes of the first replaced character from range. If no existing characters are replaced by the edit, the new characters inherit the attributes of the character preceding range if it has any, otherwise of the character following range. If the initial string is empty, the attributes for the new characters are also empty.

(Note: This function is not yet implemented and will return NULL except for toll-free bridged instances.)

CFMutableAttributedStringMBS.RemoveAttribute(Range as CFRangeMBS, attrName as CFStringMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Removes the value of a single attribute over the specified range, which should be valid.

It's OK for the attribute not the exist over the specified range.

CFMutableAttributedStringMBS.ReplaceAttributedString(Range as CFRangeMBS, Replacement as CFStringMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Replaces the attributed substring over the specified range with the attributed string specified in replacement.

range should be valid. To delete a range of the attributed string, call ReplaceString() with empty string and specified range.

CFMutableAttributedStringMBS.ReplaceString(Range as CFRangeMBS, Replacement as CFStringMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Modifies the string for the attributed string, much like CFString.Replace.

It's an error for range to specify characters outside the bounds of aStr.

CFMutableAttributedStringMBS.SetAttribute(Range as CFRangeMBS, attrName as CFStringMBS, Value as CFObjectMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets the value of a single attribute over the specified range, which should be valid.

value should not be nil.

CFMutableAttributedStringMBS.SetAttributes(Range as CFRangeMBS, replacements as CFDictionaryMBS, clearOtherAttributes as boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Sets the value of multiple attributes over the specified range, which should be valid.

If clearOtherAttributes is false, existing attributes (which aren't being replaced) are left alone; otherwise they are cleared. The dictionary should be setup for "usual" CF type usage --- CFString keys, and arbitrary CFType values. Note that after this call, further mutations to the replacement dictionary argument by the caller will not affect the contents of the attributed string.

The items on this page are in the following plugins: MBS MacCF Plugin.


The biggest plugin in space...