從 OSX lion 上的版本瀏覽器恢復不起作用...想法? (Restoring from versions browser on OSX lion not working... ideas?)


問題描述

從 OSX lion 上的版本瀏覽器恢復不起作用...想法? (Restoring from versions browser on OSX lion not working... ideas?)

I'm trying to restore a document based application from a previous version on Lion.  When I select "restore version", the text view doesn't reflect the changes.  However, if I close the application and reopen, the changes are there.

I'm using the file wrapper variants of NSDocument, so how can I make the text view's text storage reflect the version that's selected immediately?  Am I missing something?

‑‑‑‑‑

參考解法

方法 1:

I had a similar problem recently (my interface didn't seem to update). Are you updating your interface in windowControllerDidLoadNib: or awakeFromNib ? When a document is reverted (revert to last saved, or selecting a version in the versions browser), windowControllerDidLoadNib: is not called again because the document is already loaded, but your file wrapper method will be.

I'm not sure if this is the best solution, but what I do is update the UI in the read wrapper method only if the document is being reverted. I do this by checking if an outlet (like your textview) is not nil.

Update:

A better solution is overriding ‑revertToContentsOfURL:ofType:error:

‑ (BOOL)revertToContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError * __autoreleasing *)outError
{
    BOOL reverted = [super revertToContentsOfURL:absoluteURL ofType:typeName error:outError];
    if (reverted)
    {
        // re‑update interface
    }
    return reverted;
}

(by DexterWZorg)

參考文件

  1. Restoring from versions browser on OSX lion not working... ideas? (CC BY‑SA 3.0/4.0)

#cocoa #autosave #nstextview #osx-lion






相關問題

為什麼 NSWindow 或 NSView 實例處理它自己的鍵事件,而不是它的委託? (Why does an NSWindow or NSView instance handle its own key events, and not its delegate?)

通過 IKImage 視圖預覽圖像 (Previewg images via IKImage View)

Gaya Jendela Kustom di Kakao (Custom Window Style in Cocoa)

Apakah NSURLConnections termasuk dalam model atau pengontrol saya? (Do NSURLConnections belong in my model or controller?)

Эквівалент ключа NMenuItem не працуе, калі меню схавана (NSMenuItem Key Equivalent not working when menu is hidden)

透明窗口中的圓形 NSView (Rounded NSView in a Transparent Window)

單元格中不可見的 UITextField 已將 userInteractionEnabled 設置為 No (UITextField in cell that is not visible has userInteractionEnabled set to No)

如何為自定義 NSImageRep 子類實現 -draw (How to implement -draw for custom NSImageRep subclass)

從 Objective-C 中的核心數據元素獲取和設置值? (Getting and Setting values from Core Data elements in Objective-C?)

來自 URL 編碼問題的 NSArray (NSArray from URL encoding problem)

停靠欄下的窗口化opengl遊戲中的雙光標 (Double cursor in windowed opengl game under dock)

在特定的 NSTableview 單元格中對角線繪製線條 (Draw Lines Diagonally in a particular NSTableview cell)







留言討論