Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

async await apis for ios 13

extension URLSession {
    @available(iOS, deprecated: 15.0, message: "This extension is no longer necessary. Use API built into SDK")
    func data(from url: URL) async throws -> (Data, URLResponse) {
        try await withCheckedThrowingContinuation { continuation in
            let task = self.dataTask(with: url) { data, response, error in
                guard let data = data, let response = response else {
                    let error = error ?? URLError(.badServerResponse)
                    return continuation.resume(throwing: error)
                }
                
                continuation.resume(returning: (data, response))
            }
            
            task.resume()
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: command compileswift failed with a nonzero exit code 
Swift :: uiviewcontroller title color 
Swift :: create a dictionary in swift 
Swift :: Swift break statement with nested loops 
Swift :: Assignment Operators Swift 
Swift :: Swift Optional Binding (if-let 
Swift :: swift multiline comment 
Swift :: Example: Multiple Return Values 
Swift :: Autoclosure Swift 
Swift :: Iterate Over enum Cases Swift 
Swift :: Declare Variables in Swift 
Swift :: swift api call certificate 
Swift :: view rounded corners swift 
Swift :: Memberwise Initializer Swift 
Swift :: swift 5 on return button action 
Swift :: swift collectionview ispagingenabled change page size 
Swift :: Swift Logical Operators 
Swift :: UICollectionviewcontroller reload data 
Ruby :: button with icon rails 
Ruby :: how drop model rails 
Ruby :: get current year in ruby 
Ruby :: ruby get file folder 
Ruby :: ruby map with index 
Ruby :: ruby symbolize_keys 
Ruby :: remove gem rails 
Ruby :: generate csv ruby 
Ruby :: ruby loop each with index 
Ruby :: check type in ruby 
Ruby :: rails params require check exists 
Ruby :: helper path outside view 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =