My second day working with Cocoa. I’ve got an NSTextView set up, its attributed string is bound to an NSArrayController (I’m using Core Data):
controller key: selection
model key path: myString
I’ve read that an NSTextView needs an NSAttributedString, which is why it’s throwing an exception when trying to set the value of the attribute.
NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "myString"; desired type = NSString; given type = NSConcreteAttributedString;
Any ideas how I can get my managedObject’s NSString attribute to be shown in an NSTextView?
You can use a NSValueTransformer subclass to go back and forth
Caveat Emptor – This might be upside down and the reverser might leak. I just made it now but it should point you in the right direction. Let me know and ill correct the answer if its wrong.
You can type the class name
XXStringTransformerinto the binding panel or do it programmatically.