• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CoreData and NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData and NSTextView


  • Subject: Re: CoreData and NSTextView
  • From: John Timmer <email@hidden>
  • Date: Fri, 20 May 2005 22:28:06 -0400

Title: Re: CoreData and NSTextView
I just handled this in my own app recently.  Basically, store the text as NSData, and bind the textview's RTF data to that.  In my case, the text was stored as a value called “notes”.  I subclassed NSManagedObject, and had the “setNotes:” method do the following:

   [self willChangeValueForKey: @"notes"];
    [self willChangeValueForKey: @"searchableNotes"];
    
    [self setPrimitiveValue: value forKey: @"notes"];
    
    if ( value != nil ) {
        NSAttributedString *notesString = [[[NSAttributedString alloc] initWithRTF: value documentAttributes: nil] autorelease];
        if ( notesString != nil )
            [searchableNotes setString: [notesString string]];
        else
           [searchableNotes setString: @""];
    }
    else
       [searchableNotes setString: @""];
    
    [self didChangeValueForKey: @"notes"];
    [self didChangeValueForKey: @"searchableNotes"];

Searchable notes was just a mutable string that I made accessor methods for, with the “setSearchableNotes:” method doing nothing.  Works great.

Cheers,

JT


>      If I set it up as a binary type, and allow multiple fonts,  the  
> text that is pasted in an instance of NSConcreteData-something-or-
> other.  So no exception is thrown, but now the text is stored as a  
> binary string.  My concern with this is how it may effect searches,  
> etc.  Will a search on a binary filed work?
>
>      Ideally, I'd like the NSTextView to handle rich text.  So what  
> is the best way of accomplishing this?  Thanks.



_______________________________________________
This mind intentionally left blank
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >CoreData and NSTextView (From: T Reaves <email@hidden>)

  • Prev by Date: Re: Can an object's relationship point to itself?
  • Next by Date: Re: SyncConduit.framework
  • Previous by thread: CoreData and NSTextView
  • Next by thread: Re: CoreData and NSTextView
  • Index(es):
    • Date
    • Thread