Re: How to remove an item from recentDocumentURLs
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