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.
Subclass NSManagedObject, add the "searchableNotes" method, and make all the
objects with a "notes" key subclasses of this.
Assume that the "searchableNotes" method won't change, and just add it in to
any classes that need it.
I'm leaning towards the middle option since it seems the cleanest, but was
wondering if there were other reasons to favor one or another of these?
Out of the options you provide, I personally like the first one since it doesn't force a data class to inherit something just for this one bit of functionality. It's the least rigid option.
You might also consider making a full-fledged Note Entity, which can have multiple representations. This might give you the ability to have some extra features too.