• 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: How to remove an item from recentDocumentURLs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to remove an item from recentDocumentURLs


  • Subject: Re: How to remove an item from recentDocumentURLs
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 24 Sep 2010 08:44:59 -0700

On 2010 Sep 22, at 11:11, bmaclist wrote:

> f a valid document gets into my 'Recent Documents' menu, and then gets corrupted such that I am unable to open it, how can I programmatically remove it from the Recent Documents list (without removing everything in the list)?

Create a category on NSDocumentController and add this…


/*!
 @brief    Removes a document with a given URL from the receiver's
 list of Recent Documents

 @details  Due to lack of sufficient API from Apple, this method
 actually removes *all* recent documents, then replaces all except
 the one specified.  Seems to work OK, though.
*/
- (void)forgetRecentDocumentUrl:(NSURL*)url ;


- (void)forgetRecentDocumentUrl:(NSURL*)url {
    if (url) {
        NSArray* recentDocumentURLs = [self recentDocumentURLs] ;
        [self clearRecentDocuments:self] ;
        // Because noteNewRecentDocumentURL: adds to the top
        // of the list, I need a reverse enumeration to avoid
        // reversing the order of the remaining recent documents
        NSEnumerator* e = [recentDocumentURLs reverseObjectEnumerator] ;
        for (NSURL* aUrl in e) {
            if (![aUrl isEqual:url]) {
                [self noteNewRecentDocumentURL:aUrl] ;
            }
        }
    }
}


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How to remove an item from recentDocumentURLs (From: bmaclist <email@hidden>)

  • Prev by Date: Re: Subclass NSTableView
  • Next by Date: Re: Cocoa Text System - Temporarily Disabling Layout
  • Previous by thread: How to remove an item from recentDocumentURLs
  • Next by thread: TableView and SplitView Display Problem
  • Index(es):
    • Date
    • Thread