I am implementing this SO post Custom Core Data SectionNameKeyPath : in particular, Martin R's first suggestion of adding a category method to feed my sectionNameKeyPath
.
There, they have one persistent attribute called acctPeriod to be used for the sort descriptor, and one category method called periodYear which works on acctPeriod (to be precise, extracts its first 4 characters). However, I have many persistent attributes like acctPeriod, any of which could be chosen by the user for the sort descriptor, and I want to implement the same method on them to feed as sectionNameKeyPath
. In other words, I want to pass acctPeriod as an argument to the category method, like periodYear:(NSString
*) acctPeriod
Is this possible? How would the code for such a category method and FRC (sectionNameKeyPath
) look?
Thanks!