Re: Localized sorting of a Core Data entity

2011-04-08 Thread Ray
First: Quincey, Dado, Chase, WT, thanks for your comments, much appreciated! On Apr 7, 2011, at 6:53 PM, Quincey Morris wrote: On Apr 7, 2011, at 03:06, Ray wrote: Right, I tried something like this earlier, but when I use - (NSString*) localizedName { return NSLocalizedString

Localized sorting of a Core Data entity

2011-04-07 Thread Ray
Let's say I have a Core Data entity called TestEntity. It has a property called name, and I inserted three instances in the managed object, saved, etc. The value name for these three instances are A, B, and C respectively. Now I am going to fetch these managed objects using an instance of

Re: Localized sorting of a Core Data entity

2011-04-07 Thread Quincey Morris
On Apr 7, 2011, at 01:09, Ray wrote: When switching to the new language, the sorting in the table view is Z, Y, X, because it is using the original sort order of the name values... My question is: what would be a good strategy to have the whole thing sort to X, Y, Z in the table view when

Re: Localized sorting of a Core Data entity

2011-04-07 Thread Ray
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

Re: Localized sorting of a Core Data entity

2011-04-07 Thread Quincey Morris
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:

Re: Localized sorting of a Core Data entity

2011-04-07 Thread Dado Colussi
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. The SQL store, on the other hand, compiles the predicate and sort descriptors to SQL

Re: Localized sorting of a Core Data entity

2011-04-07 Thread Quincey Morris
On Apr 7, 2011, at 10:30, Dado Colussi wrote: The SQL store, on the other hand, compiles the predicate and sort descriptors to SQL and evaluates the result in the database itself. This is done primarily for performance, but it means that evaluation happens in a non-Cocoa environment, and

Re: Localized sorting of a Core Data entity

2011-04-07 Thread Chase Latta
This is just a shot in the dark and I am not sure how feasible it is, but, could you have put a property on your entity that is non-transient and represents the current localized representation of the string. This way you could do something like this when fetching your values: if (storedLanguage

Re: Localized sorting of a Core Data entity

2011-04-07 Thread Quincey Morris
On Apr 7, 2011, at 11:23, Chase Latta wrote: Assuming that your users won't be changing their language that often the overhead in translating the names would be very limited. Functionally, what you suggest seems feasible, but because we're talking about iOS, I think there are other

Re: Localized sorting of a Core Data entity

2011-04-07 Thread WT
On Apr 7, 2011, at 3:23 PM, Chase Latta wrote: Also, I don't actually know if you can register to receive notifications when the user changes their language preference You can: NSCurrentLocaleDidChangeNotification WT === autoupdatingCurrentLocale Returns the current logical locale for the