Re: Using core data binary and string attributes with NSTextView
Re: Using core data binary and string attributes with NSTextView
- Subject: Re: Using core data binary and string attributes with NSTextView
- From: Matt Neuburg <email@hidden>
- Date: Sun, 18 Oct 2009 11:33:23 -0700
- Thread-topic: Using core data binary and string attributes with NSTextView
On Sat, 17 Oct 2009 16:14:29 -0700, Robert <email@hidden> said:
>Now, after a lot of googling, I'm working on a solution that involves
>having a new transient attribute in my model of type string (let's
>call it storyText) that will mirror the text held in the binary data
>story attribute. Instead of my search field using the "story"
>attribute, it will use the "storyText" attribute.
>To do this, I created .m and .h files for my model, and I'm
>implementing the accessor and setter for the storyText attribute. In
>the accessor method, I get, using valueForKey, the story object. The
>question now is, what do I do with it? It appears that this object is
>an NSData object. Am I correct about this? What do I do with it to
>get it into an NSAttributed string on which I can extract the string?
Look at the binding for your TextView. It's getting its attributed string
from the managed object by passing the NSData through the
NSUnarchiveFromData transformer, right? So that's what *you* want to do -
unarchive the NSData to get an NSAttributedString.
As an aside, I would suggest you consider making the plain text version
*not* transient. In my Diary app, for example, the text that the user sees
and types in the NSTextView can have styles, but the text that the user
searches is a plain-text string. So when it's time to search, we don't need
to *create* the plain-text string - it's already there.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden