Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

NSAttributedStringMBS.AsCFAttributedString as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 14.2 Yes No No Yes, macOS only No
Function: Returns a new CFAttributedStringMBS object pointing to same attributed string.
Example:
// make NS version
dim n as new NSAttributedStringMBS

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

// and check content
MsgBox c.String
end if
Notes: For passing to functions which need a CFAttributedStringMBS.

Feedback, Comments & Corrections

NSAttributedStringMBS.attributeAtIndex(name as string, location as UInt64) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: 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.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.attributeAtIndex(name as string, location as UInt64, inRange as NSRangeMBS) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: 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.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.attributeAtIndex2(name as string, location as UInt64, byref effectiveRange as NSRangeMBS) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: 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.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.attributeAtIndex2(name as string, location as UInt64, byref longestEffectiveRange as NSRangeMBS, inRange as NSRangeMBS) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: 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.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.attributedSubstringFromRange(range as NSRangeMBS) as NSAttributedStringMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns an NSAttributedString object consisting of the characters and attributes within a given range in the receiver.
Notes:
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.

Feedback, Comments & Corrections

NSAttributedStringMBS.attributesAtIndex(location as UInt64) as dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns the attributes for the character at a given index.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.attributesAtIndex(location as UInt64, inRange as NSRangeMBS) as dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns the attributes for the character at a given index, and by reference the range over which the attributes apply.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.attributesAtIndex2(location as UInt64, byref range as NSRangeMBS) as dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns the attributes for the character at a given index.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.attributesAtIndex2(location as UInt64, byref range as NSRangeMBS, inRange as NSRangeMBS) as dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Returns the attributes for the character at a given index, and by reference the range over which the attributes apply.
Notes:
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:

Feedback, Comments & Corrections

NSAttributedStringMBS.copy as NSAttributedStringMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.6 Yes No No Yes, macOS only No
Function: Creates a copy of the attributed string.

Feedback, Comments & Corrections

NSAttributedStringMBS.dataFromRange(offset as Integer, length as Integer, documentAttributes as dictionary = nil, byref error as NSErrorMBS) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Returns an data object that contains a text stream corresponding to the characters and attributes within the given range.
Notes:
offset and length: The range.
documentAttributes: A required dictionary specifying the document attributes. The dictionary contains values from Document Types and must at least contain NSDocumentTypeDocumentAttribute.
error: An in-out variable containing an encountered error, if any.

Returns the data for the attributed string, or nil if failure. When nil, error encapsulates the error information.
Raises an NSRangeException if any part of range lies beyond the end of the receiver’s characters.

Feedback, Comments & Corrections

NSAttributedStringMBS.docFormatFromRange(documentAttributes as dictionary = nil) as MemoryBlock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.4 Yes No No Yes, macOS only No
Function: Creates DOC data from the whole string.
Notes:
Same as docFormatFromRange(0,length)
Returns nil on failure.
documentAttributes can optionally be a dictionary with document attributes like author or title.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.docFormatFromRange(offset as Integer, length as Integer, documentAttributes as dictionary = nil) as MemoryBlock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Creates DOC data from the current string range.
Notes:
Returns nil on failure.
documentAttributes can optionally be a dictionary with document attributes like author or title.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.fileWrapperFromRange(offset as Integer, length as Integer, documentAttributes as dictionary = nil, byref Error as NSErrorMBS) as NSFileWrapperMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Returns an NSFileWrapper object that contains a text stream corresponding to the characters and attributes within the given range.
Example:
// get styled text from htmlviewer
dim w as WebViewMBS = HTMLViewer1.WebViewMBS
dim f as WebFrameMBS = w.mainFrame
dim v as WebFrameViewMBS = f.frameView
dim d as WebDocumentViewMBS = v.documentView
dim n as NSAttributedStringMBS = d.attributedString


// package it
dim da as new Dictionary
da.Value(n.NSDocumentTypeDocumentAttribute) = n.NSRTFDTextDocumentType

dim e as NSErrorMBS
dim fw as NSFileWrapperMBS = n.fileWrapperFromRange(0, n.Length, da, e)
if e <> nil then
MsgBox e.LocalizedDescription
Return
end if

// write to disk
dim file as FolderItem = SpecialFolder.Desktop.Child("test.rtfd")
if fw.writeToFile(file, e) then
MsgBox "OK"
else
MsgBox e.LocalizedDescription
end if
Notes:
offset and length: The range.
documentAttributes: A required dictionary specifying the document attributes. The dictionary contains values from Document Types and must at least contain NSDocumentTypeDocumentAttribute.
error: An in-out variable containing an encountered error, if any.

Returns a file wrapper for the appropriate document type, or nil if failure. When nil, error encapsulates the error information.

Raises an NSRangeException if any part of range lies beyond the end of the receiver’s characters.

Feedback, Comments & Corrections

NSAttributedStringMBS.GeneratePDF(PrintOptions as Variant = nil) as MemoryBlock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 16.0 Yes No No Yes, macOS only No
Function: Creates a PDF for attributed string.
Example:
// read file
dim fi as FolderItem = SpecialFolder.Desktop.Child("test.docx")

dim d as new Dictionary
dim n as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithPath(fi, d)

// write pdf
dim p as MemoryBlock = n.GeneratePDF(nil)

dim fo as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim bo as BinaryStream = BinaryStream.Create(fo)
bo.Write p
Notes: PrintOptions is optional NSPrintInfoMBS object for print settings like margin.

Feedback, Comments & Corrections

NSAttributedStringMBS.htmlString as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 7.8 Yes No No Yes, macOS only No
Function: A self made function to return the text content as html string preserving the style information.
Example:
dim s as NSAttributedStringMBS

s=new NSAttributedStringMBS

if s.initwithhtml("<b>Hello</b>") then
MsgBox s.htmlstring // shows "<b>Hello</b>"
MsgBox s.text // shows "Hello"
end if
Notes:
Does not always work well, but can help.
(Apple has no official function for this)

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithAttributedString(text as NSAttributedStringMBS) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Initializes string with content of the given attributed string.
Notes: Returns true on success.

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithDocFormat(data as MemoryBlock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Initializes string with content of given DOC file data.
Notes:
Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithDocFormat(data as memoryblock, byref documentAttributes as dictionary) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Initializes string with content of given DOC file data.
Notes:
Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithHTML(data as MemoryBlock) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Initializes string with content of given HTML file data.
Example:
dim n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("<b>test</b>") then
MsgBox n.text
else
MsgBox "failed"
end if

dim attribText as new NSAttributedStringMBS
dim text as string = "<P>Hello öäü</P>"

text = ConvertEncoding(text, encodings.ISOLatin1)

If attribText.initWithHTML(text) Then
MsgBox attribText.text
End If
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

With plugin version 9.4 this uses the system function to parse html. The old plugin function is available with the name initWithHTMLOld.

On Mac OS X 10.6 the text encoding expected is ISO Latin 1 as far as I see.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithHTML(data as MemoryBlock, BaseURL as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 7.2 Yes No No Yes, macOS only No
Function: Initializes the object with html code from a given url.
Example:
dim n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("<b>test</b>","http://www.apple.com") then
MsgBox n.text
else
MsgBox "failed"
end if
Notes:
Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithHTML(data as memoryblock, BaseURL as string, byref documentAttributes as dictionary) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Initializes the object with html code from a given url.
Notes:
Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithHTML(data as memoryblock, byref documentAttributes as dictionary) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Initializes string with content of given HTML file data.
Notes:
Returns true on success.
documentAttributes: Optional dictionary to receive the attributes.

With plugin version 9.4 this uses the system function to parse html. The old plugin function is available with the name initWithHTMLOld.

On Mac OS X 10.6 the text encoding expected is ISO Latin 1 as far as I see.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithHTMLOld(data as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.4 Yes No No Yes, macOS only No
Function: Initializes string with content of given HTML file data.
Notes: With plugin version 9.4 the initWithHTML method uses the system function to parse html. The old plugin function is available with the name initWithHTMLOld.

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithPath(file as folderitem) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.4 Yes No No Yes, macOS only No
Function: Initializes string with content of file at the given file.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithPath(file as folderitem, byref documentAttributes as dictionary) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Initializes string with content of file at the given file.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithPath(path as string) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 9.4 Yes No No Yes, macOS only No
Function: Initializes string with content of file at the given path string.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithPath(path as string, byref documentAttributes as dictionary) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa MBS MacBase Plugin 12.0 Yes No No Yes, macOS only No
Function: Initializes string with content of file at the given path string.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

Next items

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




Links
MBS Xojo PDF Plugins