• 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: Core Data and localized sort on iOS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data and localized sort on iOS


  • Subject: Re: Core Data and localized sort on iOS
  • From: Kyle Sluder <email@hidden>
  • Date: Thu, 03 Jan 2013 09:11:01 -0800

On Jan 3, 2013, at 8:49 AM, Fritz Anderson <email@hidden> wrote:

> iOS 6
>
> I have (or will have) a Core Data store, one entity of which has an attribute that is a French word. French collates differently than English or a naïve Unicode sort would. My application will have both English and French localizations. It is next-to-nonnegotiable that the word lists I present be sorted in French order, regardless of the current locale. There will be 74,000 instances; I'd like to have tables that narrow down by incremental prefix searches.
>
> NSString has comparison methods that can take account of a specified locale, so if I'm working in code, I don't (I hope) have a problem.
>
> But I'd like to get ordered results from Core Data fetches. My first impression is that I could use the …comparator: versions of NSSortDescriptor, and put my localized comparison in the block. But I know Core Data is often pickier about what NSFetchRequest will do for you. The examples in the documentation are confined to …Key:ascending: descriptors.
>
> I have three questions.
>
> 1. Are block-comparator sort descriptors permitted in NSFetchRequest?

Not for SQL stores. Unsure about XML. Supported for in-memory.

>
> 2. If so, am I setting myself up for unacceptable performance?
>
> 3. If so, can you suggest another approach?

In-memory scan? 74,000 items might not be all that many to fault in and sort.

Alternatively, manually maintain an English and a French index when updating your data. Dunno of the best strategy here. the naive solution is to have a "french_index" and "english_index" column, but updating all the rows in your database just to handle a single insertion at the front of the list seems like a bad idea. But if your word list is static, that seems like the perfect approach.

--Kyle Sluder
_______________________________________________

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


References: 
 >Core Data and localized sort on iOS (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Core Data and localized sort on iOS
  • Next by Date: Re: scroll bars and visible rect
  • Previous by thread: Core Data and localized sort on iOS
  • Next by thread: Core Data and localized sort on iOS
  • Index(es):
    • Date
    • Thread