One of my core data subclasses has an NSSet
of items
. It is often (but not always, so no NSOrderedSet
) useful to instead retrieve an ordered NSArray
, so I added orderedItems
to the class, which sorts them.
I then ran into performance issues so decided to try caching the orderedItems
. My plan is to use an iVar, _cachedOrderedItems
in the class, which I will return if it is not null.
The snag comes with my use of categories. I read some good advice about putting all of my custom code in a category so that I can re-generate the core data class if necessary and not lose all my customizations. One of those customizations is the orderedItems
method.
It seems I can not declare an iVar in the category itself. And if I try to put it in the core data class instead, I can not access it in the category.
Do I need to move my custom code back into the core data class? Or am I missing something?
I have also heard about Mogenerator, and would consider learning to use this if it would help.