我用 NSUserDefaults 弄清楚了。
var userDefault = NSUserDefaults.standardUserDefaults()var folderPath: NSURL? { didSet { do { let bookmark = try folderPath?.bookmarkDataWithOptions(.SecurityScopeAllowOnlyReadAccess, includingResourcevaluesForKeys: nil, relativeToURL: nil) userDefault.setObject(bookmark, forKey: "bookmark") } catch let error as NSError { print("Set Bookmark Fails: (error.description)") } }}func applicationDidFinishLaunching(aNotification: NSNotification) { if let bookmarkData = userDefault.objectForKey("bookmark") as? NSData { do { let url = try NSURL.init(byResolvingBookmarkdata: bookmarkData, options: .WithoutUI, relativeToURL: nil, bookmarkDataIsStale: nil) url.startAccessingSecurityScopedResource() } catch let error as NSError { print("Bookmark Access Fails: (error.description)") } }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)