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

Previous items

NSAttributedStringMBS.initWithRTF(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 RTF file data.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithRTF(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 RTF file data.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithRTFD(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 RTFD file data.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithRTFD(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 RTFD file data.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithString(text 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 string with content of given plain text.
Example:
dim n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("test") then
MsgBox n.text
else
MsgBox "failed"
end if
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithString(text as string, withAttributes 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 plain text.
Example:
dim n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithHTML("test") then
MsgBox n.text
else
MsgBox "failed"
end if
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithURL(file as folderitem) 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 file at the given file.
Example:
dim n as NSAttributedStringMBS
n=new NSAttributedStringMBS
if n.initWithURL(SpecialFolder.Desktop.Child("testfile")) then
MsgBox n.text
else
MsgBox "failed"
end if
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithURL(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.
Example:
dim n as NSAttributedStringMBS
dim documentAttributes as dictionary
n=new NSAttributedStringMBS
if n.initWithURL(SpecialFolder.Desktop.Child("testfile"), documentAttributes) then
MsgBox n.text
else
MsgBox "failed"
end if
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithURL(url 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 string with content of file at the given url.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.initWithURL(url 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 url.
Notes:
documentAttributes: Optional dictionary to receive the attributes.
Returns true on success.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.isEqualToAttributedString(other 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: Compares both strings.
Example:
dim n as NSAttributedStringMBS
dim m as NSAttributedStringMBS

n=new NSAttributedStringMBS
if n.initWithString("test") then
MsgBox n.text
else
MsgBox "failed"
end if

m=new NSAttributedStringMBS
if m.initWithString("test") then
MsgBox n.text
else
MsgBox "failed"
end if

if m.isEqualToAttributedString(n) then
MsgBox "Ok"
else
MsgBox "failed"
end if

m=new NSAttributedStringMBS
if m.initWithString("test2") then
MsgBox n.text
else
MsgBox "failed"
end if

if m.isEqualToAttributedString(n) then
MsgBox "failed"
else
MsgBox "Ok"
end if
Notes: Returns true if they are equal in content.

Feedback, Comments & Corrections

NSAttributedStringMBS.mutableCopy as NSMutableAttributedStringMBS
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 mutable copy of the attributed string.
Example:
// create Hello World in red
dim a as NSAttributedStringMBS = NSAttributedStringMBS.attributedStringWithString("Hello World")
dim m as NSMutableAttributedStringMBS = a.mutableCopy

m.addAttribute(a.NSForegroundColorAttributeName, NSColorMBS.redColor, new NSRangeMBS(0, m.length))

// put it in a textarea
TextArea1.NSTextViewMBS.textStorage.setAttributedString m

Feedback, Comments & Corrections

NSAttributedStringMBS.rtf 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: Returns the content of this attributed string as a RTF string.
Example:
dim s as NSAttributedStringMBS

s=new NSAttributedStringMBS

if s.initWithString("Hello") then
MsgBox s.RTF
end if

// shows this text:
// {\rtf1\ansi\ansicpg1252\cocoartf949
// {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
// {\colortbl;\red255\green255\blue255;}
// \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
//
// \f0\fs24 \cf0 Hello}
Notes: Same as RTFFromRange(0,length)

Feedback, Comments & Corrections

NSAttributedStringMBS.RTFDFileWrapperFromRange(offset as Integer, length as Integer, documentAttributes as dictionary = nil) 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 an RTFD document 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. If there are no document-level attributes, dict can be nil.

Returns a file wrapper containing the RTFD data.

The file wrapper also includes the document-level attributes in docAttributes, as explained in RTF Files and Attributed Strings.
Raises an NSRangeException if any part of aRange lies beyond the end of the receiver’s characters.
You can save the file wrapper using the NSFileWrapper method writeToFile.

Feedback, Comments & Corrections

NSAttributedStringMBS.RTFDFromRange(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 RTFD data from the current string range.
Notes:
Returns nil on failure.
Same as RTFDFromRange(0,length)
documentAttributes can optionally be a dictionary with document attributes like author or title.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.RTFDFromRange(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 RTFD 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.RTFFromRange(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 RTF data from whole string.
Notes:
Returns nil on failure.
Same as RTFFromRange(0,length)
documentAttributes can optionally be a dictionary with document attributes like author or title.

See also:

Feedback, Comments & Corrections

NSAttributedStringMBS.RTFFromRange(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 RTF data from the current string range.
Example:
// get some attributed text:
dim t as new NSAttributedStringMBS
call t.initWithString("Hello World")

// set document attributes
dim dic as new Dictionary
dic.Value(t.NSBottomMarginDocumentAttribute) = 20
dic.Value(t.NSLeftMarginDocumentAttribute) = 20
dic.Value(t.NSRightMarginDocumentAttribute) = 20
dic.Value(t.NSTopMarginDocumentAttribute) = 20
dic.Value(t.NSAuthorDocumentAttribute) = "Test User"

// get rtf
dim rtf as string = t.RTFFromRange(dic)

// write to file
dim f as FolderItem = SpecialFolder.Desktop.Child("test.rtf")
dim b as BinaryStream = BinaryStream.Create(f, true)
b.Write rtf
Notes:
Returns nil on failure.
documentAttributes can optionally be a dictionary with document attributes like author or title.

See also:

Feedback, Comments & Corrections

Previous items

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




Links
MBS Xojo Plugins