Platforms to show: All Mac Windows Linux Cross-Platform

Back to CFAttributedStringMBS class.

CFAttributedStringMBS.AsNSAttributedString 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 NSAttributedStringMBS object pointing to same attributed string.
Example
// make CF version
dim c as CFAttributedStringMBS = CFAttributedStringMBS.Create("Hello World", nil)
MsgBox c.String

// get NS Version
dim n as NSAttributedStringMBS = c.AsNSAttributedString
MsgBox n.text

For passing to functions which need a NSAttributedStringMBS.

CFAttributedStringMBS.AttributeAndLongestEffectiveRange(location as Integer, attrName as CFStringMBS, inRange as CFRangeMBS, byref effectiveRange as CFRangeMBS) as CFObjectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the value of a given attribute of an attributed string at a specified location.

location: The location in str at which to determine the attributes. It is a programming error for loc to specify a location outside the bounds of str.
attrName: The name of the attribute whose value you want to determine.
inRange: The range in str within which you want to find the longest effective range of the attributes at loc. inRange must not exceed the bounds of str.
effectiveRange: upon return contains the maximal range within inRange over which the exact same set of attributes apply. The returned range is clipped to inRange.
Returns the attribute value of str at the specified location.

CFAttributedStringMBS.AttributesAndLongestEffectiveRange(location as Integer, inRange as CFRangeMBS, byref effectiveRange as CFRangeMBS) as CFDictionaryMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the attributes of an attributed string at a specified location.

location: The location in str at which to determine the attributes. loc must not exceed the bounds of str.
inRange: The range in str within to find the longest effective range of the attributes at loc. inRange must not exceed the bounds of str.
effectiveRange: upon return contains the maximal range within inRange over which the exact same set of attributes apply. The returned range is clipped to inRange.

CFAttributedStringMBS.AttributesDictionary(location as Integer, byref effectiveRange as CFRangeMBS) as CFDictionaryMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the attributes of an attributed string at a specified location.

location: The location in str at which to determine the attributes. loc must not exceed the bounds of str.
effectiveRange: upon return contains a range including loc over which exactly the same set of attributes apply as at loc.

Returns a dictionary that contains the attributes of str at the specified location. Ownership follows the Get Rule.

For performance reasons, a range returned in effectiveRange is not necessarily the maximal range. If you need the maximum range, you should use AttributesAndLongestEffectiveRange.

Note that the returned attribute dictionary might change in unpredictable ways if the attributed string is edited after this call. If you want to preserve the state of the dictionary, you should make an actual copy of it rather than just retaining it. In addition, you should make no assumptions about the relationship of the actual dictionary returned by this call and the dictionary originally used to set the attributes, other than the fact that the values stored in the dictionaries will be identical (that is, ==) to those originally specified.

CFAttributedStringMBS.AttributeValue(location as Integer, attrName as CFStringMBS, byref effectiveRange as CFRangeMBS) as CFObjectMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the value of a given attribute of an attributed string at a specified location.

location: The location in str at which to determine the attributes. loc must not exceed the bounds of str.
attrName: The name of the attribute whose value you want to determine.
effectiveRange: upon return contains a range including loc over which exactly the same set of attributes apply as at location.

Returns the value of the specified attribute at the specified location in str. Ownership follows the Get Rule.

For performance reasons, a range returned in effectiveRange is not necessarily the maximal range. If you need the maximum range, you should use AttributeAndLongestEffectiveRange.

CFAttributedStringMBS.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:

CFAttributedStringMBS.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:

CFAttributedStringMBS.Copy as CFAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an immutable copy of an attributed string.

CFAttributedStringMBS.GetLength as Integer   Deprecated

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 10.3 ✅ Yes ❌ No ❌ No ✅ Yes All
This item is deprecated and should no longer be used.
Queries the length of the string.

Deprecated in favor of Length property.

CFAttributedStringMBS.GetString as CFStringMBS   Deprecated

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 10.3 ✅ Yes ❌ No ❌ No ✅ Yes All
This item is deprecated and should no longer be used.
Queries the text of the attributed string.

Deprecated in favor of String function.

CFAttributedStringMBS.MutableCopy(maxLength as Integer = 0) as CFAttributedStringMBS

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

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.

CFAttributedStringMBS.String as CFStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreFoundation MBS MacCF Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the string for an attributed string.

For performance reasons, the string returned will often be the backing store of the attributed string, and it might therefore change if the attributed string is edited. However, this is an implementation detail, and you should not rely on this behavior.

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


The biggest plugin in space...