Drunken Daddy
Drunken Daddy

Reputation: 8001

Xamarin NSTextStorage from NSAttributedString

I trying to port this line to xamarin

let textStorage = NSTextStorage(attributedString: self.attributedText!)

but I can't find a constructor or static method that takes an NSAttributedString.

Upvotes: 2

Views: 222

Answers (1)

SushiHangover
SushiHangover

Reputation: 74174

NSTextStorage's attributedString: initializer is missing on Xamarin.iOS.

You can perform an Append|Insert on your NSTextStorage object (which is really appending/inserting on the NSMutableAttributedString subclass).

Since your NSTextStorage would be empty as it was just instanced, just use Append:

var textStorage = new NSTextStorage();
textStorage.Append(someMutableAttributedString);

Note: This initializer was manually added to the Xamarin.Mac's AppKit framework as a partial class (something in the API generator must not like how it is defined).

Upvotes: 5

Related Questions