FROM : Julio Cesar Silva dos Santos
DATE : Wed Aug 23 15:42:06 2006
Just for the records, post the solution too! Can you figure out a
newbie following this thread and finding out that you just 'got it'?
Very frustrating...
Julio Cesar Silva dos Santos
<email_removed>
Blogjective-C
http://www.jcs.santos.nom.br/wp
FetchYourLyrics
http://www.jcs.santos.nom.br/fyl/fyl.html
On 23/08/2006, at 10:19, Joe Goh wrote:
> Just a few minutes after sending this email, I suddenly "got it" and
> found out what the problem was, and fixed it in about 90 seconds, a
> problem which i've been struggling for 6 hours today. DOH!
>
> On 8/23/06, Joe Goh <<email_removed>> wrote:
>> On Jun 22, 2006, at 5:18 AM, Alexander Lamb wrote:
>>
>> > I have a core data application.
>> >
>> > I would like to force the sort on a given column when the data is
>> > loaded in my NSArrayController and displayed in the NSTableView.
>> > Sorting works fine manually (e.g. when clicking on the column
>> > header) so I would like to do as if the used had clicked.
>> >
>> > I know I can sort programmatically the objects in my controller,
>> > but I want to show the visual feedback of my column with the little
>> > sort triangle.
>>
>> I am now facing the exact same problem as Alexander did, and after
>> trying the solution suggested to him and many others posted on
>> various
>> blogs/forums for the past six hours, I still can't get it working.
>> :-(
>>
>> Here's the solution given to Alexander,
>>
>> On Jun 22, 2006, at 11:20 AM, George Orthwein wrote:
>>
>> > Ah, it's actually setSortDescriptors you want. Set it in
>> > windowControllerDidLoadNib:
>> >
>> > NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc]
>> > initWithKey: @"displayOrder" ascending: YES] autorelease];
>> > [tableView setSortDescriptors:[NSArray
>> > arrayWithObject:sortDescriptor]];
>>
>> I placed the following code in the awakeFromNib method for the
>> NSTableView subclass (ContactView), as i'm not writing a
>> document-based app:
>>
>> @implementation ContactView
>> - (void) awakeFromNib
>> {
>> NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc]
>> initWithKey: @"name" ascending: YES] autorelease];
>>
>> [self setSortDescriptors:[NSArray
>> arrayWithObject:sortDescriptor]];
>> [self reloadData]; // Is this needed?
>> }
>> @end
>>
>> I have only one column in my NSTableView, and using bindings/Core
>> Data, the "name" attribute is now successfully being shown in the
>> view, and it can be sorted when I click on the header, but not when
>> the application first starts.
>>
>> Is "name" the correct argument to use as a key for NSSortDescriptor's
>> initWithKey? Any other clues as to why the column is still not being
>> sorted by default when the application starts?
>>
>> Thanks in advance,
>> Joe
DATE : Wed Aug 23 15:42:06 2006
Just for the records, post the solution too! Can you figure out a
newbie following this thread and finding out that you just 'got it'?
Very frustrating...
Julio Cesar Silva dos Santos
<email_removed>
Blogjective-C
http://www.jcs.santos.nom.br/wp
FetchYourLyrics
http://www.jcs.santos.nom.br/fyl/fyl.html
On 23/08/2006, at 10:19, Joe Goh wrote:
> Just a few minutes after sending this email, I suddenly "got it" and
> found out what the problem was, and fixed it in about 90 seconds, a
> problem which i've been struggling for 6 hours today. DOH!
>
> On 8/23/06, Joe Goh <<email_removed>> wrote:
>> On Jun 22, 2006, at 5:18 AM, Alexander Lamb wrote:
>>
>> > I have a core data application.
>> >
>> > I would like to force the sort on a given column when the data is
>> > loaded in my NSArrayController and displayed in the NSTableView.
>> > Sorting works fine manually (e.g. when clicking on the column
>> > header) so I would like to do as if the used had clicked.
>> >
>> > I know I can sort programmatically the objects in my controller,
>> > but I want to show the visual feedback of my column with the little
>> > sort triangle.
>>
>> I am now facing the exact same problem as Alexander did, and after
>> trying the solution suggested to him and many others posted on
>> various
>> blogs/forums for the past six hours, I still can't get it working.
>> :-(
>>
>> Here's the solution given to Alexander,
>>
>> On Jun 22, 2006, at 11:20 AM, George Orthwein wrote:
>>
>> > Ah, it's actually setSortDescriptors you want. Set it in
>> > windowControllerDidLoadNib:
>> >
>> > NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc]
>> > initWithKey: @"displayOrder" ascending: YES] autorelease];
>> > [tableView setSortDescriptors:[NSArray
>> > arrayWithObject:sortDescriptor]];
>>
>> I placed the following code in the awakeFromNib method for the
>> NSTableView subclass (ContactView), as i'm not writing a
>> document-based app:
>>
>> @implementation ContactView
>> - (void) awakeFromNib
>> {
>> NSSortDescriptor* sortDescriptor = [[[NSSortDescriptor alloc]
>> initWithKey: @"name" ascending: YES] autorelease];
>>
>> [self setSortDescriptors:[NSArray
>> arrayWithObject:sortDescriptor]];
>> [self reloadData]; // Is this needed?
>> }
>> @end
>>
>> I have only one column in my NSTableView, and using bindings/Core
>> Data, the "name" attribute is now successfully being shown in the
>> view, and it can be sorted when I click on the header, but not when
>> the application first starts.
>>
>> Is "name" the correct argument to use as a key for NSSortDescriptor's
>> initWithKey? Any other clues as to why the column is still not being
>> sorted by default when the application starts?
>>
>> Thanks in advance,
>> Joe
| Related mails | Author | Date |
|---|---|---|
| Joe Goh | Aug 23, 15:08 | |
| Joe Goh | Aug 23, 15:19 | |
| Julio Cesar Silva… | Aug 23, 15:42 |






Cocoa mail archive

