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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to