Skip to content

Latest commit

 

History

History
109 lines (70 loc) · 3.72 KB

README_CN.md

File metadata and controls

109 lines (70 loc) · 3.72 KB

 LCAppSandboxFileKit 是一个用于写入和访问 macOS 应用程序沙盒文件之外的文件的功能的框架!

中文 | English

如何使用

  • 定义需要授权的路径
let authorizedDirectory = "/"
  • 清除指定路径的访问权限
LCAppSandboxFileKit.standard.clearAccessForPath(authorizedDirectory) { status in
    if status {
        print("Successfully cleared access to the root directory.")
    } else {
        print("Failed to clear access to the root directory.")
    }
}
  • 检查目录是否有访问权限
let isPermiss = LCAppSandboxFileKit.standard.checkAccessForPath(authorizedDirectory)
if isPermiss {
    print("Directory access granted, starting search.")
} else { // No access, request permission
    print("No directory access, requesting permission.")
    LCAppSandboxFileKit.standard.requestAccessForPath(authorizedDirectory, canChooseDirectories: true) { status in
        if status {
            print("Permission granted, proceeding with the process.")
        } else {
            print("Failed to obtain permission.")
        }
    }
}

设计

安装

CocoaPods

PermissionsKit 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中:

pod 'LCAppSandboxFileKit'

SwiftPackage

添加 https://github.com/DevLiuSir/LCAppSandboxFileKit.git Xcode 中的“Swift Package Manager”选项卡.

许可证

MIT License

Copyright (c) 2024 Marvin

作者

DevLiuSir

Software Engineer