LoginSignup
2
1

More than 1 year has passed since last update.

【Swift】他アプリからファイルを受け取る

Last updated at Posted at 2022-03-11

備忘録

iOS15

受け取るファイルの拡張子を指定

スクリーンショット 2022-03-11 17.27.00.png

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    
    var window: UIWindow?
    
    
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        if let url = connectionOptions.urlContexts.first?.url {
            save(url)
        }
        guard let _ = (scene as? UIWindowScene) else { return }
    }
    
    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        guard let url = URLContexts.first?.url else {
            return
        }
        save(url)
    }
    
    private func save(_ url: URL) {
        //urlを使ってローカルへコピー
    }
    
}

2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1