NSAttributedString Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
NSAttributedString()
Creates a new NSAttributedString with default values.
[Foundation.Export("init")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString();
- Attributes
Applies to
NSAttributedString(String, NSFont, NSColor, NSColor, NSColor, NSColor, NSColor, NSUnderlineStyle, NSUnderlineStyle, NSParagraphStyle, Single, NSShadow, NSUrl, Boolean, NSTextAttachment, NSLigatureType, Single, Single, Single, Single, NSCursor, String, Int32, NSGlyphInfo, NSArray, Boolean, NSTextLayoutOrientation, NSTextAlternatives, NSSpellingState)
public NSAttributedString(string str, AppKit.NSFont? font = default, AppKit.NSColor? foregroundColor = default, AppKit.NSColor? backgroundColor = default, AppKit.NSColor? strokeColor = default, AppKit.NSColor? underlineColor = default, AppKit.NSColor? strikethroughColor = default, Foundation.NSUnderlineStyle underlineStyle = Foundation.NSUnderlineStyle.PatternSolid, Foundation.NSUnderlineStyle strikethroughStyle = Foundation.NSUnderlineStyle.PatternSolid, AppKit.NSParagraphStyle? paragraphStyle = default, float strokeWidth = 0, AppKit.NSShadow? shadow = default, Foundation.NSUrl? link = default, bool superscript = false, AppKit.NSTextAttachment? attachment = default, Foundation.NSLigatureType ligature = Foundation.NSLigatureType.Default, float baselineOffset = 0, float kerningAdjustment = 0, float obliqueness = 0, float expansion = 0, AppKit.NSCursor? cursor = default, string? toolTip = default, int characterShape = 0, AppKit.NSGlyphInfo? glyphInfo = default, Foundation.NSArray? writingDirection = default, bool markedClauseSegment = false, AppKit.NSTextLayoutOrientation verticalGlyphForm = AppKit.NSTextLayoutOrientation.Horizontal, AppKit.NSTextAlternatives? textAlternatives = default, AppKit.NSSpellingState spellingState = AppKit.NSSpellingState.None);
new Foundation.NSAttributedString : string * AppKit.NSFont * AppKit.NSColor * AppKit.NSColor * AppKit.NSColor * AppKit.NSColor * AppKit.NSColor * Foundation.NSUnderlineStyle * Foundation.NSUnderlineStyle * AppKit.NSParagraphStyle * single * AppKit.NSShadow * Foundation.NSUrl * bool * AppKit.NSTextAttachment * Foundation.NSLigatureType * single * single * single * single * AppKit.NSCursor * string * int * AppKit.NSGlyphInfo * Foundation.NSArray * bool * AppKit.NSTextLayoutOrientation * AppKit.NSTextAlternatives * AppKit.NSSpellingState -> Foundation.NSAttributedString
Parameters
- str
- String
- font
- NSFont
- foregroundColor
- NSColor
- backgroundColor
- NSColor
- strokeColor
- NSColor
- underlineColor
- NSColor
- strikethroughColor
- NSColor
- underlineStyle
- NSUnderlineStyle
- strikethroughStyle
- NSUnderlineStyle
- paragraphStyle
- NSParagraphStyle
- strokeWidth
- Single
- shadow
- NSShadow
- link
- NSUrl
- superscript
- Boolean
- attachment
- NSTextAttachment
- ligature
- NSLigatureType
- baselineOffset
- Single
- kerningAdjustment
- Single
- obliqueness
- Single
- expansion
- Single
- cursor
- NSCursor
- toolTip
- String
- characterShape
- Int32
- glyphInfo
- NSGlyphInfo
- writingDirection
- NSArray
- markedClauseSegment
- Boolean
- verticalGlyphForm
- NSTextLayoutOrientation
- textAlternatives
- NSTextAlternatives
- spellingState
- NSSpellingState
Applies to
NSAttributedString(String, UIFont, UIColor, UIColor, UIColor, NSParagraphStyle, NSLigatureType, Single, NSUnderlineStyle, NSShadow, Single, NSUnderlineStyle)
Creates a UIKit attributed string with the specified attributes in the parameters.
public NSAttributedString(string str, UIKit.UIFont? font = default, UIKit.UIColor? foregroundColor = default, UIKit.UIColor? backgroundColor = default, UIKit.UIColor? strokeColor = default, UIKit.NSParagraphStyle? paragraphStyle = default, Foundation.NSLigatureType ligatures = Foundation.NSLigatureType.Default, float kerning = 0, Foundation.NSUnderlineStyle underlineStyle = Foundation.NSUnderlineStyle.PatternSolid, UIKit.NSShadow? shadow = default, float strokeWidth = 0, Foundation.NSUnderlineStyle strikethroughStyle = Foundation.NSUnderlineStyle.PatternSolid);
new Foundation.NSAttributedString : string * UIKit.UIFont * UIKit.UIColor * UIKit.UIColor * UIKit.UIColor * UIKit.NSParagraphStyle * Foundation.NSLigatureType * single * Foundation.NSUnderlineStyle * UIKit.NSShadow * single * Foundation.NSUnderlineStyle -> Foundation.NSAttributedString
Parameters
- str
- String
String to create.
- font
- UIFont
Desired font (or null, if none is desired).
- foregroundColor
- UIColor
Desired foreground color (or null if none is desired).
- backgroundColor
- UIColor
Desired background color (or null if none is desired)..
- strokeColor
- UIColor
Desired stroke color (or null if none is desired).
- paragraphStyle
- NSParagraphStyle
- ligatures
- NSLigatureType
- kerning
- Single
- underlineStyle
- NSUnderlineStyle
- shadow
- NSShadow
Desired shadow.
- strokeWidth
- Single
Desired stroked width..
- strikethroughStyle
- NSUnderlineStyle
Remarks
This is the recommended constructor for NSAttributedString objects that are intended to be unique.
The advantage of this constructor is that other than the string, every parameter is optional. It provides a convenient way of creating the objects
//
// This example shows how to create an NSAttributedString for
// use with UIKit without creating the attributes separately
//
var text = new NSAttributedString (
"Hello, World",
font: UIFont.FromName ("HoeflerText-Regular", 24.0f),
foregroundColor: UIColor.Red,
strokeWidth: 4
);
For cases where the same attributes will be reused across multiple attributed strings, it is best to create the attributes using the UIStringAttributes class as that will share the same dictionary across multiple uses while this constructor creates a dictionary on demand for the specified attributes in the constructor.
Applies to
NSAttributedString(NSData, NSDictionary, NSDictionary, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[Foundation.Export("initWithData:options:documentAttributes:error:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSData data, Foundation.NSDictionary options, out Foundation.NSDictionary resultDocumentAttributes, ref Foundation.NSError error);
[Foundation.Export("initWithData:options:documentAttributes:error:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSData data, Foundation.NSDictionary options, out Foundation.NSDictionary docAttributes, out Foundation.NSError error);
[<Foundation.Export("initWithData:options:documentAttributes:error:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)>]
new Foundation.NSAttributedString : Foundation.NSData * Foundation.NSDictionary * NSDictionary * NSError -> Foundation.NSAttributedString
Parameters
- data
- NSData
- resultDocumentAttributesdocAttributes
- NSDictionary
- error
- NSError
- Attributes
Applies to
NSAttributedString(String, NSAttributedStringMarkdownParsingOptions, NSUrl, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[Foundation.Export("initWithMarkdownString:options:baseURL:error:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(string markdownString, Foundation.NSAttributedStringMarkdownParsingOptions? options, Foundation.NSUrl? baseUrl, out Foundation.NSError? error);
[<Foundation.Export("initWithMarkdownString:options:baseURL:error:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)>]
new Foundation.NSAttributedString : string * Foundation.NSAttributedStringMarkdownParsingOptions * Foundation.NSUrl * NSError -> Foundation.NSAttributedString
Parameters
- markdownString
- String
- baseUrl
- NSUrl
- error
- NSError
- Attributes
Applies to
NSAttributedString(NSUrl, NSDictionary, NSDictionary, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[Foundation.Export("initWithURL:options:documentAttributes:error:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSUrl url, Foundation.NSDictionary options, out Foundation.NSDictionary resultDocumentAttributes, ref Foundation.NSError error);
[Foundation.Export("initWithURL:options:documentAttributes:error:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSUrl url, Foundation.NSDictionary options, out Foundation.NSDictionary resultDocumentAttributes, out Foundation.NSError error);
[<Foundation.Export("initWithURL:options:documentAttributes:error:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)>]
new Foundation.NSAttributedString : Foundation.NSUrl * Foundation.NSDictionary * NSDictionary * NSError -> Foundation.NSAttributedString
Parameters
- url
- NSUrl
- resultDocumentAttributes
- NSDictionary
- error
- NSError
- Attributes
Applies to
NSAttributedString(NSUrl, NSAttributedStringMarkdownParsingOptions, NSUrl, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[Foundation.Export("initWithContentsOfMarkdownFileAtURL:options:baseURL:error:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSUrl markdownFile, Foundation.NSAttributedStringMarkdownParsingOptions? options, Foundation.NSUrl? baseUrl, out Foundation.NSError? error);
[<Foundation.Export("initWithContentsOfMarkdownFileAtURL:options:baseURL:error:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)>]
new Foundation.NSAttributedString : Foundation.NSUrl * Foundation.NSAttributedStringMarkdownParsingOptions * Foundation.NSUrl * NSError -> Foundation.NSAttributedString
Parameters
- markdownFile
- NSUrl
- baseUrl
- NSUrl
- error
- NSError
- Attributes
Applies to
NSAttributedString(NSUrl, NSAttributedStringDocumentAttributes, NSDictionary, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSUrl url, Foundation.NSAttributedStringDocumentAttributes options, out Foundation.NSDictionary resultDocumentAttributes, ref Foundation.NSError error);
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSUrl url, Foundation.NSAttributedStringDocumentAttributes options, out Foundation.NSDictionary resultDocumentAttributes, out Foundation.NSError error);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)>]
new Foundation.NSAttributedString : Foundation.NSUrl * Foundation.NSAttributedStringDocumentAttributes * NSDictionary * NSError -> Foundation.NSAttributedString
Parameters
- url
- NSUrl
- resultDocumentAttributes
- NSDictionary
- error
- NSError
- Attributes
Applies to
NSAttributedString(NSData, NSAttributedStringMarkdownParsingOptions, NSUrl, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[Foundation.Export("initWithMarkdown:options:baseURL:error:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSData markdown, Foundation.NSAttributedStringMarkdownParsingOptions? options, Foundation.NSUrl? baseUrl, out Foundation.NSError? error);
[<Foundation.Export("initWithMarkdown:options:baseURL:error:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)>]
new Foundation.NSAttributedString : Foundation.NSData * Foundation.NSAttributedStringMarkdownParsingOptions * Foundation.NSUrl * NSError -> Foundation.NSAttributedString
Parameters
- markdown
- NSData
- baseUrl
- NSUrl
- error
- NSError
- Attributes
Applies to
NSAttributedString(NSData, NSAttributedStringDocumentAttributes, NSDictionary, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSData data, Foundation.NSAttributedStringDocumentAttributes options, out Foundation.NSDictionary resultDocumentAttributes, ref Foundation.NSError error);
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)]
public NSAttributedString(Foundation.NSData data, Foundation.NSAttributedStringDocumentAttributes options, out Foundation.NSDictionary resultDocumentAttributes, out Foundation.NSError error);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.", false)>]
new Foundation.NSAttributedString : Foundation.NSData * Foundation.NSAttributedStringDocumentAttributes * NSDictionary * NSError -> Foundation.NSAttributedString
Parameters
- data
- NSData
- resultDocumentAttributes
- NSDictionary
- error
- NSError
- Attributes
Applies to
NSAttributedString(NSUrl, NSAttributedStringDocumentAttributes, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSUrl url, Foundation.NSAttributedStringDocumentAttributes documentAttributes, ref Foundation.NSError error);
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSUrl url, Foundation.NSAttributedStringDocumentAttributes documentAttributes, out Foundation.NSError error);
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")>]
new Foundation.NSAttributedString : Foundation.NSUrl * Foundation.NSAttributedStringDocumentAttributes * NSError -> Foundation.NSAttributedString
Parameters
- url
- NSUrl
- documentAttributes
- NSAttributedStringDocumentAttributes
- error
- NSError
- Attributes
Applies to
NSAttributedString(NSData, NSUrl, NSDictionary)
Caution
Use 'CreateWithHTML' instead.
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use 'CreateWithHTML' instead.", false)]
public NSAttributedString(Foundation.NSData htmlData, Foundation.NSUrl baseUrl, out Foundation.NSDictionary docAttributes);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use 'CreateWithHTML' instead.", false)>]
new Foundation.NSAttributedString : Foundation.NSData * Foundation.NSUrl * NSDictionary -> Foundation.NSAttributedString
Parameters
- htmlData
- NSData
- baseUrl
- NSUrl
- docAttributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(NSData, NSDictionary, NSDictionary)
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(Foundation.NSData data, Foundation.NSDictionary? options, out Foundation.NSDictionary resultDocumentAttributes);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : Foundation.NSData * Foundation.NSDictionary * NSDictionary -> Foundation.NSAttributedString
Parameters
- data
- NSData
- options
- NSDictionary
- resultDocumentAttributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(NSData, NSAttributedStringDocumentAttributes, NSDictionary)
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(Foundation.NSData data, Foundation.NSAttributedStringDocumentAttributes options, out Foundation.NSDictionary resultDocumentAttributes);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : Foundation.NSData * Foundation.NSAttributedStringDocumentAttributes * NSDictionary -> Foundation.NSAttributedString
Parameters
- data
- NSData
- resultDocumentAttributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(String, UIStringAttributes)
public NSAttributedString(string str, UIKit.UIStringAttributes? attributes);
new Foundation.NSAttributedString : string * UIKit.UIStringAttributes -> Foundation.NSAttributedString
Parameters
- str
- String
- attributes
- UIStringAttributes
Applies to
NSAttributedString(NSData, NSAttributedStringDocumentAttributes, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSData data, Foundation.NSAttributedStringDocumentAttributes documentAttributes, ref Foundation.NSError error);
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSData data, Foundation.NSAttributedStringDocumentAttributes documentAttributes, out Foundation.NSError error);
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")>]
new Foundation.NSAttributedString : Foundation.NSData * Foundation.NSAttributedStringDocumentAttributes * NSError -> Foundation.NSAttributedString
Parameters
- data
- NSData
- documentAttributes
- NSAttributedStringDocumentAttributes
- error
- NSError
- Attributes
Applies to
NSAttributedString(String, NSDictionary)
[Foundation.Export("initWithString:attributes:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(string str, Foundation.NSDictionary? attributes);
[<Foundation.Export("initWithString:attributes:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : string * Foundation.NSDictionary -> Foundation.NSAttributedString
Parameters
- str
- String
- attributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(NSAttributedString)
[Foundation.Export("initWithAttributedString:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(Foundation.NSAttributedString other);
[<Foundation.Export("initWithAttributedString:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : Foundation.NSAttributedString -> Foundation.NSAttributedString
Parameters
- other
- NSAttributedString
- Attributes
Applies to
NSAttributedString(NSCoder)
A constructor that initializes the object from the data stored in the unarchiver object.
[Foundation.Export("initWithCoder:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[ObjCRuntime.DesignatedInitializer]
public NSAttributedString(Foundation.NSCoder coder);
[<Foundation.Export("initWithCoder:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<ObjCRuntime.DesignatedInitializer>]
new Foundation.NSAttributedString : Foundation.NSCoder -> Foundation.NSAttributedString
Parameters
- coder
- NSCoder
The unarchiver object.
- Attributes
Remarks
This constructor is provided to allow the class to be initialized from an unarchiver (for example, during NIB deserialization). This is part of the NSCoding protocol.
If developers want to create a subclass of this object and continue to support deserialization from an archive, they should implement a constructor with an identical signature: taking a single parameter of type NSCoder and decorate it with the [Export("initWithCoder:"] attribute.
The state of this object can also be serialized by using the EncodeTo(NSCoder) companion method.
Applies to
NSAttributedString(NSObjectFlag)
Constructor to call on derived classes to skip initialization and merely allocate the object.
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
protected NSAttributedString(Foundation.NSObjectFlag t);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : Foundation.NSObjectFlag -> Foundation.NSAttributedString
Parameters
Unused sentinel value, pass NSObjectFlag.Empty.
- Attributes
Remarks
This constructor should be called by derived classes when they completely construct the object in managed code and merely want the runtime to allocate and initialize the NSObject. This is required to implement the two-step initialization process that Objective-C uses, the first step is to perform the object allocation, the second step is to initialize the object. When developers invoke this constructor, they take advantage of a direct path that goes all the way up to NSObject to merely allocate the object's memory and bind the Objective-C and C# objects together. The actual initialization of the object is up to the developer.
This constructor is typically used by the binding generator to allocate the object, but prevent the actual initialization to take place. Once the allocation has taken place, the constructor has to initialize the object. With constructors generated by the binding generator this means that it manually invokes one of the "init" methods to initialize the object.
It is the developer's responsibility to completely initialize the object if they chain up using this constructor chain.
In general, if the developer's constructor invokes the corresponding base implementation, then it should also call an Objective-C init method. If this is not the case, developers should instead chain to the proper constructor in their class.
The argument value is ignored and merely ensures that the only code that is executed is the construction phase is the basic NSObject allocation and runtime type registration. Typically the chaining would look like this:
//
// The NSObjectFlag constructor merely allocates the object and registers the C# class with the Objective-C runtime if necessary.
// No actual initXxx method is invoked, that is done later in the constructor
//
// This is taken from the iOS SDK's source code for the UIView class:
//
[Export ("initWithFrame:")]
public UIView (CGRect frame) : base (NSObjectFlag.Empty)
{
// Invoke the init method now.
var initWithFrame = new Selector ("initWithFrame:").Handle;
if (IsDirectBinding) {
Handle = ObjCRuntime.Messaging.IntPtr_objc_msgSend_CGRect (this.Handle, initWithFrame, frame);
} else {
Handle = ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_CGRect (this.SuperHandle, initWithFrame, frame);
}
}
Applies to
NSAttributedString(NativeHandle)
A constructor used when creating managed representations of unmanaged objects. Called by the runtime.
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
protected internal NSAttributedString(ObjCRuntime.NativeHandle handle);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : ObjCRuntime.NativeHandle -> Foundation.NSAttributedString
Parameters
- handle
- NativeHandle
Pointer (handle) to the unmanaged object.
- Attributes
Remarks
This constructor is invoked by the runtime infrastructure (GetNSObject(IntPtr)) to create a new managed representation for a pointer to an unmanaged Objective-C object. Developers should not invoke this method directly, instead they should call GetNSObject(IntPtr) as it will prevent two instances of a managed object pointing to the same native object.
Applies to
NSAttributedString(String, NSDictionary)
[Foundation.Export("initWithPath:documentAttributes:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(string path, out Foundation.NSDictionary resultDocumentAttributes);
[<Foundation.Export("initWithPath:documentAttributes:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : string * NSDictionary -> Foundation.NSAttributedString
Parameters
- path
- String
- resultDocumentAttributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(NSData, NSDictionary)
Caution
Use 'CreateWithDocFormat' instead.
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
[System.Obsolete("Use 'CreateWithDocFormat' instead.", false)]
public NSAttributedString(Foundation.NSData wordDocFormat, out Foundation.NSDictionary docAttributes);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
[<System.Obsolete("Use 'CreateWithDocFormat' instead.", false)>]
new Foundation.NSAttributedString : Foundation.NSData * NSDictionary -> Foundation.NSAttributedString
Parameters
- wordDocFormat
- NSData
- docAttributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(String)
[Foundation.Export("initWithString:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(string str);
[<Foundation.Export("initWithString:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : string -> Foundation.NSAttributedString
Parameters
- str
- String
- Attributes
Applies to
NSAttributedString(NSFileWrapper, NSDictionary)
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(Foundation.NSFileWrapper wrapper, out Foundation.NSDictionary resultDocumentAttributes);
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : Foundation.NSFileWrapper * NSDictionary -> Foundation.NSAttributedString
Parameters
- wrapper
- NSFileWrapper
- resultDocumentAttributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(NSUrl, NSDictionary)
[Foundation.Export("initWithURL:documentAttributes:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public NSAttributedString(Foundation.NSUrl url, out Foundation.NSDictionary resultDocumentAttributes);
[<Foundation.Export("initWithURL:documentAttributes:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
new Foundation.NSAttributedString : Foundation.NSUrl * NSDictionary -> Foundation.NSAttributedString
Parameters
- url
- NSUrl
- resultDocumentAttributes
- NSDictionary
- Attributes
Applies to
NSAttributedString(NSUrl, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSUrl url, ref Foundation.NSError error);
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSUrl url, out Foundation.NSError error);
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")>]
new Foundation.NSAttributedString : Foundation.NSUrl * NSError -> Foundation.NSAttributedString
Parameters
- url
- NSUrl
- error
- NSError
- Attributes
Applies to
NSAttributedString(String, NSStringAttributes)
public NSAttributedString(string str, AppKit.NSStringAttributes? attributes);
new Foundation.NSAttributedString : string * AppKit.NSStringAttributes -> Foundation.NSAttributedString
Parameters
- str
- String
- attributes
- NSStringAttributes
Applies to
NSAttributedString(String, CTStringAttributes)
Creates an NSAttributedString for use with CoreText rendering functions.
public NSAttributedString(string str, CoreText.CTStringAttributes? attributes);
new Foundation.NSAttributedString : string * CoreText.CTStringAttributes -> Foundation.NSAttributedString
Parameters
- str
- String
String.
- attributes
- CTStringAttributes
CoreText string attributes.
Applies to
NSAttributedString(NSData, NSError)
Caution
Use the 'Create' method instead, because there's no way to return an error from a constructor.
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSData data, ref Foundation.NSError error);
[System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")]
public NSAttributedString(Foundation.NSData data, out Foundation.NSError error);
[<System.Obsolete("Use the 'Create' method instead, because there's no way to return an error from a constructor.")>]
new Foundation.NSAttributedString : Foundation.NSData * NSError -> Foundation.NSAttributedString
Parameters
- data
- NSData
- error
- NSError
- Attributes