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 NSFetchedResultsController, use a UITableview for rendering, etc. I use a 
NSSortDescriptor to sort the objects by "name" in the table view, something 
like:

NSSortDescriptor *sortDescriptor =
[[NSSortDescriptor alloc] initWithKey:"name"
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)];

All works swimmingly, I get a table view which shows A, B, C, sorted correctly.

Now I add a .strings file with a localization for "A", "B", and "C":

"A" = "Z";
"B" = "Y";
"C" = "X";

In my cellForRowAtIndexPath method, I use something like:

...

NSManagedObject *obj = [self.fetchedResultsController 
objectAtIndexPath:indexPath];
cell.textLabel.text = NSLocalizedString([obj valueForKey:"name"], nil);

...

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 using the new language? I can't seem to figure this one 
out...

Thanks,
- Ray.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to