Re: Sorting problem
"jbs_mailuk" <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.newbies |
|---|---|
| Message-ID | <[email protected]> |
OK, I think I've solved this. The problem is not that the sortArrayUsingKeyOrderArray() doesn't call my method - it's that it doesn't necessarily sort in-place, which is what it's supposed to do. It sometimes creates a new list and updates the fed-in ref to point to this. This threw me off as I also used a cached reference to the array (assuming it would be valid post-sort i.e. sorted in place!), which didn't point to the sorted list after the sort. Solved by updating this cached ref just after sorting. I've not fully investigated this, but it looks like using a derived attribute can cause this - I've not found this to happen using normal attribs. So far I've found that if the derived method returns an 'int', this problem occurs, while a 'String' works as it should. Has anyone else found this 'feature'? John --- In [email protected], "jbs_mailuk" <jbs_mailuk@y...> wrote: > Hi! > > I'm trying to sort an array of objects (in an NSMutableArray) by using > EOSortOrdering.sortArrayUsingKeyOrderArray(). > > I can do this easily on normal attributes. However, I need to sort on > a derived attribute, i.e. a method. In this case, myValue(). > > Where do I put this method? I've tried putting it in the myObject > class as public, but it's not being called by the sort. I've tried > variations such as getMyValue() and private _myValue() and > _getMyValue(), but so far no joy. The docs say it should be possible, > but I'm clearly missing out something necessary. > > Any ideas? > > TIA, > John Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/webobjects-newbies/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/