INNER CODE UNIT · Swift

documentPicker

cometchat/cometchat-uikit-flutter · packages/cometchat_uikit/ios/Classes/SwiftCometchatChatUikitPlugin.swift:311

    public func documentPicker(_ controller: UIDocumentPickerViewController,
    didPickDocumentsAt urls: [URL]) {
        var files = [[String: String]]()
        for url in urls {
            // Security-scoped resource: copy to app's tmp dir so the file
            // remains accessible after the picker dismisses.
            let accessing = url.startAccessingSecurityScopedResource()
            defer { if accessing { url.stopAccessingSecurityScopedResource() } }

            let tmpDir = FileManager.default.temporaryDirectory
            let dest = tmpDir.appendingPathComponent(url.lastPathComponent)
            // Remove stale copy if present
            try? FileManager.default.removeItem(at: dest)
            do {
                try FileManager.default.copyItem(at: url, to: dest)
                files.append([
                    "path": dest.path,
                    "name": dest.lastPathComponent

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…