{"id":77,"date":"2005-11-07T14:40:48","date_gmt":"2005-11-07T21:40:48","guid":{"rendered":"http:\/\/www.corbinstreehouse.com\/blog\/?p=77"},"modified":"2005-11-07T14:41:07","modified_gmt":"2005-11-07T21:41:07","slug":"removing-sort-descriptors-on-a-sorted-nstableview-nsoutlineview","status":"publish","type":"post","link":"https:\/\/www.corbinstreehouse.com\/blog\/2005\/11\/removing-sort-descriptors-on-a-sorted-nstableview-nsoutlineview\/","title":{"rendered":"Removing sort descriptors on a sorted NSTableView \/ NSOutlineView"},"content":{"rendered":"<p id=\"top\" \/>I&#8217;ve discovered that some people may want to programatically remove the sort descriptors for their tableview:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/RemoveSortDesc1.png\" height=\"28\" width=\"151\" border=\"1\" hspace=\"4\" vspace=\"4\" alt=\"Removesortdesc1\" \/><\/p>\n<p>This is easy to do with a little code:<\/p>\n<pre>- (IBAction)removeSorting:(id)sender {\n    [tableView setSortDescriptors:[NSArray array]];    \n}<\/pre>\n<p>However, you may want your users to be able to do it. It is fairly simple to add a button in the corner view of your table that does this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/RemoveSortDesc2.png\" height=\"36\" width=\"377\" border=\"1\" hspace=\"4\" vspace=\"4\" alt=\"Removesortdesc2\" \/><\/p>\n<p>In your awakeFromNib method you can easily add a bit of code that adds this button and invokes the above \u00e2\u20ac\u0153removeSorting:\u00e2\u20ac\u009d method:<\/p>\n<pre>    NSRect buttonFrame = [[tableView cornerView] frame];\n    NSButton *button = [[NSButton alloc] initWithFrame:buttonFrame];\n    [button setBezelStyle:NSSmallSquareBezelStyle];\n    [button setTitle:@\u00e2\u20ac\u0153X\u00e2\u20ac\u009d];\n    [button setTarget:self];\n    [button setAction:@selector(removeSorting:)];\n\n    [tableView setCornerView:button];\n    [button release];<\/pre>\n<p>Have Fun, and note that I recommend that you don&#8217;t have auto-scrollbar hiding turned on when you use this (otherwise, the corner view won&#8217;t be visible!)<\/p>\n<p>-corbin<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve discovered that some people may want to programatically remove the sort descriptors for their tableview: This is easy to do with a little code: &#8211; (IBAction)removeSorting:(id)sender { [tableView setSortDescriptors:[NSArray array]]; } However, you may&#8230; <a class=\"read-more\" href=\"https:\/\/www.corbinstreehouse.com\/blog\/2005\/11\/removing-sort-descriptors-on-a-sorted-nstableview-nsoutlineview\/\">[read more]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[6,1],"tags":[],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-cocoa","category-general"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":0,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}