2013-11-14 139 views
0

ALAssetPropertyAssetURL屬性是一種方便的方式,用於存儲對ALAsset的引用,但在系統還原(或升級)某些資產期間might change this property。儘管可能會有一些解決方法來更新資產參考網址,但我該如何檢測何時需要此資源?系統升級很簡單,但是如何檢測應用程序何時從備份恢復,以及是否發生在同一設備中?應用程序從備份中恢復時如何檢測到?

回答

4

當你的應用程序啓動,看在證件已知名稱的文件(DidLaunch.txt,說),如果它不存在,創建它,並設置其元數據「不備份」。在每次啓動時,請查找該文件 - 如果存在,則先前在此設備上啓動。如果它不在那裏,這是一次新的發射。

+0

這看起來血腥的輝煌!將試着讓你知道它是否工作,並將其設置爲相應的正確答案。謝謝! – Nuthinking

0

書籤對象是我通常如何保持對用戶在我身上移動的資源的訪問權限。

From the NSURL Class Reference

Starting in OS X v10.6, the NSURL class provides a facility for creating and using bookmark objects. A bookmark provides a persistent reference to a file-system resource. When you resolve a bookmark, you obtain a URL to the resource’s current location. A bookmark’s association with a file-system resource (typically a file or folder) usually continues to work if the user moves or renames the resource, or if the user relaunches your app or restarts the system.

我不知道它將如何處理修復從備份(聽起來像你會在操作系統的深處深挖理解那一個),但它可能是你的最好的選擇無論。

+0

它看起來像URLByResolvingBookmarkData:選擇:relativeToURL:bookmarkDataIsStale:錯誤:可從的iOS 5.0,所以我想同樣的技術也應該工作在iOS。有點害怕開始保存NSData而不是NSString(尤其是用作鍵)。 – Nuthinking