Re: Localized sorting of a Core Data entity
Re: Localized sorting of a Core Data entity
- Subject: Re: Localized sorting of a Core Data entity
- From: Quincey Morris <email@hidden>
- Date: Thu, 07 Apr 2011 09:53:44 -0700
On Apr 7, 2011, at 03:06, Ray wrote:
> Right, I tried something like this earlier, but when I use
>
> - (NSString*) localizedName {
> return NSLocalizedString (self.name, nil);
> }
>
> I get an exception:
>
> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath localizedName not found in entity <NSSQLEntity TestEntity id=1>'...
I don't see anything in the documentation for the fetch sort descriptors that says they have to specify a Core Data property, rather than a custom or derived property, although perhaps that is the problem. You didn't use this key somewhere else, like in the fetch predicate, by any chance?
An alternative approach would be to get rid of "localizedName", and to provide a custom NSArray* property (on a different object) which contains the list of names, sorted after the fetch is done. You would then use the sorted array to provide data for your table. This approach is a bit more work, because you have to recreate/update the array as objects change. However, this approach might be a bit memory-heavy for iOS.
> But then you would say I have to perhaps back it up by a real property?
You could perhaps use a transient property, whose value you create at 'awakeFromFetch', but it's not obvious to me that such an approach would work for sorting at fetch time either. You could try it experimentally.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden