Skip to content

Instantly share code, notes, and snippets.

@brendanzagaeski
Created November 11, 2013 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brendanzagaeski/7420369 to your computer and use it in GitHub Desktop.
Save brendanzagaeski/7420369 to your computer and use it in GitHub Desktop.
Subclassing NSMutableAttributedString causes an error "[CustomNSAttributedString initWithAttributedString:]: unrecognized selector sent to instance 0x4418b0"
using System;
using MonoMac.Foundation;
using MonoMac.CoreText;
using MonoMac.AppKit;
namespace SubclassingTest
{
public class Program
{
static void Main (string[] args)
{
NSApplication.Init ();
var attrs = new CTStringAttributes () {
Font = new CTFont ("HoeflerText-Regular", 24.0f),
LigatureFormation = CTLigatureFormation.All,
KerningAdjustment = 10,
UnderlineStyle = CTUnderlineStyle.Single,
StrokeWidth = 5
};
var attributedString = new NSAttributedString ("Hello world", attrs);
var customTest = new CustomNSAttributedString (attributedString);
Console.WriteLine ("customTest.ClassHandle: {0}", customTest.ClassHandle);
}
}
public class CustomNSAttributedString : NSMutableAttributedString
{
public CustomNSAttributedString (NSAttributedString other) : base (other)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment