• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Localized sorting of a Core Data entity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 02:13:34 -0700

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

It should be fairly simple to do with a derived property that you can use in the sort descriptor:

	+ (NSSet*) keyPathsForValuesAffectingLocalizedName
	{
		return [NSSet setWithObject: @"name"];
	}

	- (NSString*) localizedName
	{
		return NSLocalizedString (self.name, nil);
	}

Of course, if you don't currently have a custom subclass for the entity you'll have to create one. Also, I don't really recommend calling the property "localizedName" -- it's too generic and too likely to get confused with something in the frameworks. (For that matter, I don't recommend calling any property "name". One horrendous debugging experience with exceptions complaining about property name -- where you can't figure out whether it means a property name, or the property named "name", or one of many "name" properties you defined in lots of different classes -- is enough to put an end to that practice.)


_______________________________________________

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

  • Follow-Ups:
    • Re: Localized sorting of a Core Data entity
      • From: Ray <email@hidden>
References: 
 >Localized sorting of a Core Data entity (From: Ray <email@hidden>)

  • Prev by Date: Localized sorting of a Core Data entity
  • Next by Date: Re: Best way to find files
  • Previous by thread: Localized sorting of a Core Data entity
  • Next by thread: Re: Localized sorting of a Core Data entity
  • Index(es):
    • Date
    • Thread