• 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: EOSortOrdering based on a @count relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOSortOrdering based on a @count relationship


  • Subject: Re: EOSortOrdering based on a @count relationship
  • From: Ian Joyner <email@hidden>
  • Date: Tue, 9 Jan 2007 11:08:03 +1100

Please don't post your messages to both WO-Dev and Omni list. All people end up with is duplicate messages, since most people receive both groups.

On 09/01/2007, at 10:51 AM, Dev WO wrote:

Hi,
I've been trying to isolate the issue with this, but I just can't even get an error...
So I need to sort based on a calculated attribute: relationship ().count()


but I just can't make it work...

I've got entity "a" which has a toMany relationship "relationship()".
I need to sort "a" entities based on relationship().count().

So here's my SortOrder:
--------
    public Number numberOfComments() {
    	return (Number)writeCommentaries().count();
    }

public NSArray sortOrderingByCommentaries() {
NSMutableArray sortOrdering = new NSMutableArray();
EOSortOrdering newSO = EOSortOrdering.sortOrderingWithKey ("numberOfComments", EOSortOrdering.CompareDescending);
sortOrdering.addObject(newSO);
return (NSArray)sortOrdering;
}
--------


and the actual sorted array:
--------
public NSArray listOfNewsSortedByCommentaries() {
return (NSArray)EOSortOrdering.sortedArrayUsingKeyOrderArray (listOfNews(), new NSArray(sortOrderingByCommentaries()));
}
--------


but it won't work, I don't even get a crash, just a "no instance available"...
I tried with another Number attribute to see if it coud be the cause, but it works. I also sort using another attribute and display the relationship().count() for each "a" and it works. It seems I just can't sort using the relationship().count().


But I though I could use custom attribute as long as the array is already in an editing context.

I must miss something, but I can't find it...

Thanks for your help

Xavier

_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >EOSortOrdering based on a @count relationship (From: Dev WO <email@hidden>)

  • Prev by Date: EOSortOrdering based on a @count relationship
  • Next by Date: [OT] Programmer wanted: Sydney, Australia
  • Previous by thread: EOSortOrdering based on a @count relationship
  • Next by thread: Re: EOSortOrdering based on a @count relationship
  • Index(es):
    • Date
    • Thread