• 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: CoreData: sorting on a computed attribute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData: sorting on a computed attribute


  • Subject: Re: CoreData: sorting on a computed attribute
  • From: Volker in Lists <email@hidden>
  • Date: Fri, 15 Mar 2013 11:04:21 +0100

Hi Laurent,

when I faced a similar problem - in my case I needed to filter data acquired fromCoreData in a TableView for a field value that wasn't part of the model, but existed as an ivar in the NSManagedObject subclass - I used the following:

[self.sessionController setFilterPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
             return [(Session*)evaluatedObject fileLocationInvalid];
             }]];

Depending on the complexity of the calculation and the impact on performance you may want to do similar.

You may be able to produce a similar result by using a block as comparator function for the descriptor. Or write your own comparator function to compare the calculated values. In both cases you won't need to create a persistent attribute, but do the calculation in the sort descriptor block or compare function.

My 2cents,
Volker

Am 14.03.2013 um 18:11 schrieb Laurent Daudelin:

> I have a need to sort a CoreData table on one attribute in a table that needs to be derived from a calculation. I read about "Non-Standard Persistent Attributes" and did google and the only way I found to make it work is according to the following:
>


_______________________________________________

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: 
 >CoreData: sorting on a computed attribute (From: Laurent Daudelin <email@hidden>)

  • Prev by Date: Re: 'Pseudo' Singleton in Objective C
  • Next by Date: Re: Problems with gesture recognizer & child view controller
  • Previous by thread: CoreData: sorting on a computed attribute
  • Next by thread: 'Pseudo' Singleton in Objective C
  • Index(es):
    • Date
    • Thread