• 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: Core Data design question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data design question


  • Subject: Re: Core Data design question
  • From: mmalcolm crawford <email@hidden>
  • Date: Tue, 3 May 2005 11:15:45 -0700


On May 3, 2005, at 10:16 AM, John Timmer wrote:
I've got a series of NSManagedObjects and subclasses. Most of them have a
"notes" field holding RTF saved as NSData. I'd like to expose the text of
these notes to being searched by adding a method that makes an attributed
string out of the data and then extracts the raw string. The question is:
where do I put this method? I could:
Add a category to NSManagedObject with a "searchableNotes" method and trap
exceptions for when the "notes" key doesn't exist.


This doesn't really encapsulate application logic. (And...)

Assume that the "searchableNotes" method won't change, and just add it in to
any classes that need it.


This doesn't use the benefits of object orientation. (And...)

Subclass NSManagedObject, add the "searchableNotes" method, and make all the
objects with a "notes" key subclasses of this.


This approach is just right...

You might also consider defining an *entity* (probably abstract) from which the other entities inherit -- it would contain a searchableNotes attribute.


Depending on likely access patterns, you might also consider caching the searchableNotes. See <http://developer.apple.com/documentation/ Cocoa/Conceptual/CoreData/Articles/cdNSAttributes.html> for details of an approach to implementing this.


mmalc

_______________________________________________
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: 
 >Core Data design question (From: John Timmer <email@hidden>)

  • Prev by Date: Re: Core Data design question
  • Next by Date: Re: CoreData: Data freshness vs. multithreading
  • Previous by thread: Re: Core Data design question
  • Next by thread: Web Services, Axis, base64 madness - looking for Byron
  • Index(es):
    • Date
    • Thread