> On Dec 23, 2016, at 8:16 PM, Daryle Walker <dary...@mac.com> wrote:
> 
> The text controls on macOS use a NSTextStorage object to retain their text. 
> That object is a extension of an attributed string. Let's say you use a 
> NSString (or similar) in your document model. How should I get changes on one 
> string to get mirrored on the other?
> 
> I think there are begin/end-editing flag methods on text controls, but how 
> would I go the other way?

In my experience, real-time synchronization of vanilla NSString to an 
NSTextStorage of an NSTextView is painful and fraught with error. Much easier 
to simply set the content of the NSTextView on load (in windowDidLoad or 
whatever is apropos for your setup), and then let the NSTextView manage the 
content until editing has been committed, at which time you pull the plain 
string out and set your model property.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to