Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSAttributedStringMBS class.

NSAttributedStringMBS.AsCFAttributedString as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new CFAttributedStringMBS object pointing to same attributed string.
Example
// make NS version
Var n as new NSAttributedStringMBS

if n.initWithString("Hello World") then
// convert
Var c as CFAttributedStringMBS = n.AsCFAttributedString

// and check content
MsgBox c.String
end if

For passing to functions which need a CFAttributedStringMBS.

Some examples using this method:

NSAttributedStringMBS.attributeAtIndex(name as string, location as UInt64) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the value for an attribute with a given name of the character at a given index, and by reference the range over which the attribute applies.

name: The name of an attribute.
location: The index for which to return attributes. This value must not exceed the bounds of the receiver.
effectiveRange: Optional. If the named attribute exists at index, upon return aRange contains a range over which the named attribute's value applies. If the named attribute does not exist at index, upon return aRange contains the range over which the attribute does not exist.
The range isn't necessarily the maximum range covered by attributeName, and its extent is implementation-dependent. If you need the maximum range, use the other variant of this method.

Returns the value for the attribute named attributeName of the character at index index, or nil if there is no such attribute.
Raises an NSRangeException if index lies beyond the end of the receiver's characters.

For information about where to find the attribute keys for the returned dictionary, see the overview section of this document.

See also:

Some examples using this method:

NSAttributedStringMBS.attributeAtIndex(name as string, location as UInt64, inRange as NSRangeMBS) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the value for the attribute with a given name of the character at a given index, and by reference the range over which the attribute applies.

name: The name of an attribute.
location: The index at which to test for attributeName.
longestEffectiveRange: Optional. If the named attribute exists at index, upon return aRange contains the full range over which the value of the named attribute is the same as that at index, clipped to rangeLimit. If the named attribute does not exist at index, upon return aRange contains the full range over which the attribute does not exist, clipped to rangeLimit.
inRange: The range over which to search for continuous presence of attributeName. This value must not exceed the bounds of the receiver.

Returns the value for the attribute named attributeName of the character at index, or nil if there is no such attribute.

Raises an NSRangeException if index or any part of rangeLimit lies beyond the end of the receiver's characters.

If you don't need the longest effective range, it's far more efficient to use the other variant method to retrieve the attribute value.

For information about where to find the attribute keys for the returned dictionary, see the overview section of this document.

See also:

NSAttributedStringMBS.attributeAtIndex2(name as string, location as UInt64, byref effectiveRange as NSRangeMBS) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the value for an attribute with a given name of the character at a given index, and by reference the range over which the attribute applies.
Example
// list all links
Var n As NSAttributedStringMBS = TextArea1.NSTextViewMBS.textStorage

Var pos As Integer = 0
Var Len As Integer = n.Length
Var effectiveRange As NSRangeMBS

While pos < Len

Var v As Variant = n.attributeAtIndex2(n.NSLinkAttributeName, pos, effectiveRange)

If v <> Nil Then
Var url As String = v
Listbox1.AddRow url
End If

pos = pos + effectiveRange.Length

Wend

name: The name of an attribute.
location: The index for which to return attributes. This value must not exceed the bounds of the receiver.
effectiveRange: Optional. If the named attribute exists at index, upon return aRange contains a range over which the named attribute's value applies. If the named attribute does not exist at index, upon return aRange contains the range over which the attribute does not exist.
The range isn't necessarily the maximum range covered by attributeName, and its extent is implementation-dependent. If you need the maximum range, use the other variant of this method.

Returns the value for the attribute named attributeName of the character at index index, or nil if there is no such attribute.
Raises an NSRangeException if index lies beyond the end of the receiver's characters.

For information about where to find the attribute keys for the returned dictionary, see the overview section of this document.

See also:

NSAttributedStringMBS.attributeAtIndex2(name as string, location as UInt64, byref longestEffectiveRange as NSRangeMBS, inRange as NSRangeMBS) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the value for the attribute with a given name of the character at a given index, and by reference the range over which the attribute applies.

name: The name of an attribute.
location: The index at which to test for attributeName.
longestEffectiveRange: Optional. If the named attribute exists at index, upon return aRange contains the full range over which the value of the named attribute is the same as that at index, clipped to rangeLimit. If the named attribute does not exist at index, upon return aRange contains the full range over which the attribute does not exist, clipped to rangeLimit.
inRange: The range over which to search for continuous presence of attributeName. This value must not exceed the bounds of the receiver.

Returns the value for the attribute named attributeName of the character at index, or nil if there is no such attribute.

Raises an NSRangeException if index or any part of rangeLimit lies beyond the end of the receiver's characters.

If you don't need the longest effective range, it's far more efficient to use the other variant method to retrieve the attribute value.

For information about where to find the attribute keys for the returned dictionary, see the overview section of this document.

See also:

NSAttributedStringMBS.attributedSubstringFromRange(range as NSRangeMBS) as NSAttributedStringMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns an NSAttributedString object consisting of the characters and attributes within a given range in the receiver.

Range: The range from which to create a new attributed string. aRange must lie within the bounds of the receiver.

Returns an NSAttributedString object consisting of the characters and attributes within aRange in the receiver.

Raises an NSRangeException if any part of aRange lies beyond the end of the receiver's characters. This method treats the length of the string as a valid range value that returns an empty string.

NSAttributedStringMBS.attributesAtIndex(location as UInt64) as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the attributes for the character at a given index.

location: The index for which to return attributes. This value must lie within the bounds of the receiver.
Range: Optional. Upon return, the range over which the attributes and values are the same as those at index. This range isn't necessarily the maximum range covered, and its extent is implementation-dependent. If you need the maximum range, use other variant of this method.

Returns the attributes for the character at index.
Raises an NSRangeException if index lies beyond the end of the receiver's characters.

See also:

Some examples using this method:

NSAttributedStringMBS.attributesAtIndex(location as UInt64, inRange as NSRangeMBS) as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the attributes for the character at a given index, and by reference the range over which the attributes apply.

location: The index for which to return attributes. This value must not exceed the bounds of the receiver.
range: Optional. Upon return contains the maximum range over which the attributes and values are the same as those at index, clipped to range Limit.
inRange: The range over which to search for continuous presence of the attributes at index. This value must not exceed the bounds of the receiver.

Raises an NSRangeException if index or any part of rangeLimit lies beyond the end of the receiver's characters.
If you don't need the range information, it's far more efficient to use the other variant of this method to retrieve the attribute value.

For information about where to find the attribute keys for the returned dictionary, see the overview section of this document.

See also:

NSAttributedStringMBS.attributesAtIndex2(location as UInt64, byref range as NSRangeMBS) as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the attributes for the character at a given index.

location: The index for which to return attributes. This value must lie within the bounds of the receiver.
Range: Optional. Upon return, the range over which the attributes and values are the same as those at index. This range isn't necessarily the maximum range covered, and its extent is implementation-dependent. If you need the maximum range, use other variant of this method.

Returns the attributes for the character at index.
Raises an NSRangeException if index lies beyond the end of the receiver's characters.

See also:

NSAttributedStringMBS.attributesAtIndex2(location as UInt64, byref range as NSRangeMBS, inRange as NSRangeMBS) as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Text MBS MacBase Plugin 12.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the attributes for the character at a given index, and by reference the range over which the attributes apply.

location: The index for which to return attributes. This value must not exceed the bounds of the receiver.
range: Optional. Upon return contains the maximum range over which the attributes and values are the same as those at index, clipped to range Limit.
inRange: The range over which to search for continuous presence of the attributes at index. This value must not exceed the bounds of the receiver.

Raises an NSRangeException if index or any part of rangeLimit lies beyond the end of the receiver's characters.
If you don't need the range information, it's far more efficient to use the other variant of this method to retrieve the attribute value.

For information about where to find the attribute keys for the returned dictionary, see the overview section of this document.

See also:

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


The biggest plugin in space...