This is OrderBy.m in view mode; [Download] [Up]
/* OrderBy.m:
* You may freely copy, distribute, and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to its
* fitness for any particular use.
*
* Adam Hertz/William Shipley
*/
#import <dbkit/dbkit.h>
#import "OrderBy.h"
@implementation OrderBy
/* Could set these up in NIB -- do it here for pedagogy */
- appDidInit: sender
{
[[module rootFetchGroup] setDelegate: self];
[tableView setDelegate: self];
return self;
}
/* Set the sort order before the actual fetch */
- fetchGroupWillFetch: sender
{
if( sortProp == nil) {
sortProp = [[tableView columnAt: 0] identifier];
}
[[sender recordList]
addRetrieveOrder: DB_AscendingOrder
for: sortProp];
return self;
}
/* Find the new sort property every time the tableView column gets moved */
- tableView:sender movedColumnFrom:(unsigned int) old to:(unsigned int) new
{
sortProp = [[sender columnAt: new] identifier];
return [module fetchAllRecords: self];
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.