summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Extensions/URL+Scoping.swift
blob: a957d4291ea51bdbef504f04716ec17146182427 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//
//  URL+Scoping.swift
//  MullvadVPN
//
//  Created by Jon Petersson on 2024-02-02.
//  Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

import Foundation

extension URL {
    func securelyScoped(_ completionHandler: (Self?) -> Void) {
        if startAccessingSecurityScopedResource() {
            completionHandler(self)
            stopAccessingSecurityScopedResource()
        } else {
            completionHandler(nil)
        }
    }
}