• 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: DistinctRows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DistinctRows


  • Subject: Re: DistinctRows
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 03 Mar 2003 15:16:18 -0800
  • Organization: Global Village Consulting, Inc.

There are several ways to accomplish this, including raw SQL and fetch specs set to fetch distinct rows. But in the interests of making minimal changes...


Jonathan Fleming wrote:

If I use the code below to create a list of the EOModel attribute named navPageName, how can I then be sure to list only distinct rows? The code is used in a popup list, but instead of:
Home
Home
Home
Reference
Reference
Terms


I want to get:
Home
Reference
Terms

No Fetch spec is used to create the list.

Here's the list code:

/** @TypeInfo TbNavPage */
public NSArray sortedNavPageNames() {
// create new navPage list
EOEditingContext ec = this.session().defaultEditingContext();
NSMutableArray sortedNavPageNameList = new NSMutableArray(EOUtilities.objectsForEntityNamed(ec, "TbNavPage"));



Replace above line with:


NSArray pageNameList = EOUtilities.objectsForEntityNamed(ec, "TbNavPage");
NSSet uniquePageNameList = new NSSet(pageNameList);
NSMutableArray sortedNavPageNameList = new NSMutableArray(uniquePageNameList.allObjects());




Chuck

// Sort ordering created here to sort unsorted clients
EOSortOrdering navPageNameSortOrdering =
EOSortOrdering.sortOrderingWithKey("navPageName", EOSortOrdering.CompareAscending);


       NSArray sortOrderings =
           new NSArray( new Object[]{navPageNameSortOrdering});

       // Sort away!
       EOSortOrdering.sortArrayUsingKeyOrderArray(sortedNavPageNameList,
                                                  sortOrderings );

       return sortedNavPageNameList;
   }

   Advanced Thanks
   Jonathan



--

Chuck Hill                                 email@hidden
Global Village Consulting Inc.             http://www.global-village.net
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: DistinctRows
      • From: Art Isbell <email@hidden>
References: 
 >DistinctRows (From: "Jonathan Fleming" <email@hidden>)

  • Prev by Date: Re: 5.2 Not Responding
  • Next by Date: Re: DistinctRows
  • Previous by thread: DistinctRows
  • Next by thread: Re: DistinctRows
  • Index(es):
    • Date
    • Thread