• 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: Sorting a to-many relationship property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting a to-many relationship property


  • Subject: Re: Sorting a to-many relationship property
  • From: Keary Suska <email@hidden>
  • Date: Thu, 17 Jul 2008 08:56:23 -0600
  • Thread-topic: Sorting a to-many relationship property

7/16/08 6:37 PM, also sprach email@hidden:

> I have a couple entities related by a to-many relationship. Entity Foo
> can have 0..N of Entity Bar. I have a relationship defined on Foo
> named "bars". In my code, I build a comma-delimited string of Bars by
> iterating over the NSArray* returned by Foo.bars.
>
> But they come back in whatever order Core Data has for them. I'd
> really like for all requests for Foo.bars to come back sorted by a
> property of Bar. Is this possible? Or must I either create a new
> property that sorts them, or just sort them after I get them?

If you are finding that multiple, separate methods are requiring a sorted
array, then you probably want a built-in solution, if you don't have a
controller somewhere in the mix that can do this for you.

Any customization will involve subclassing NSManagedObject and overriding
the accessor or adding a method. I recommend the latter (adding), as
overriding the accessor would make it rather inefficient, and could effect
performance.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

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:
    • : Sorting a to-many relationship property
      • From: Keary Suska <email@hidden>
References: 
 >Sorting a to-many relationship property (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: NSMessagePort Invalidation
  • Next by Date: Re: Duplicate rows appearing in outlineview after creating new Entity in moc, why?
  • Previous by thread: Re: Sorting a to-many relationship property
  • Next by thread: : Sorting a to-many relationship property
  • Index(es):
    • Date
    • Thread