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 != currentLanguage) {
    [self translateStoredNamesToNewLanguage];
    storedLanguage = currentLanguage;
}

// fetch strings
NSSortDescriptor *sortDescriptor =
[[NSSortDescriptor alloc] initWithKey:"translatedRepresentationOfName"
ascending:YES
selector:@selector(localizedCaseInsensitiveCompare:)];

// …

You would then have a function
-- (void)translateStoredNamesToNewLanguage
{
    for ( /* all names in core data database */ ) {
        entity.translatedRepresentationOfName =
            NSLocalizedString(entity.name, nil)
    }
    // Save your manage object
}

Assuming that your users won't be changing their language that often
the overhead in translating the names would be very limited.  Also, I
don't actually know if you can register to receive notifications when
the user changes their language preference, so if you can't, I don't
think this approach would work, but if you can it might be worth a
shot.

Chase

On Thu, Apr 7, 2011 at 10:41 AM, Quincey Morris
<quinceymor...@earthlink.net> wrote:
> 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 so sort descriptors (or predicates) that rely on 
>> Cocoa cannot work." [1]
>>
>> [1] 
>> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdPersistentStores.html
>
> Ah, thanks for finding it. It's some distance away from the place I was 
> looking. Also, later in the same paragraph:
>
>> In addition you cannot sort on transient properties using the SQLite store.
>
> which nixes the other idea too.
>
>
> _______________________________________________
>
> 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/chaselatta%40gmail.com
>
> This email sent to chasela...@gmail.com
>
_______________________________________________

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