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>'...

But then you would say I have to perhaps back it up by a real property?

On Apr 7, 2011, at 11:13 AM, Quincey Morris wrote:

> 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 (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