在我今天的擴展與我的設備解鎖,這行代碼按預期運行,從圖像路徑返回數據:加載文件時,設備被鎖定
let imageData = NSData(contentsOfFile: path)
然而,當我的設備已被鎖定用密碼,它返回零。設備鎖定時,有沒有辦法訪問文件系統中的圖像?我可以很好地訪問UserDefaults,但不能訪問我的共享組的目錄中的文件。這裏是我正在創建的路徑,呼籲imagePath
,這是正確填入我希望在這兩種情況下的路徑:
func rootFilePath() -> String? {
let manager = NSFileManager()
let containerURL = manager.containerURLForSecurityApplicationGroupIdentifier(GROUP_ID)
if let unwrappedURL = containerURL {
return unwrappedURL.path
}
else {
return nil
}
}
func imagePath() -> String? {
let rootPath = rootFilePath()
if let uPath = rootPath {
return "\(uPath)/\(imageId).png"
}
else {
return nil
}
}
對此有何動靜?我遇到了同樣的問題。 – 2014-10-02 02:29:47
不...還沒有。而這個帖子上的人聲稱他根本沒有問題,儘管我不相信它,我覺得文件系統只是用密碼鎖定 - 雖然我還沒有搜索過文檔。 http://stackoverflow.com/a/25844434/431271 – ccwasden 2014-10-02 13:49:34