Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift url request

import Foundation

let apiUrl = URL(string: "https://api.chucknorris.io/jokes/random")!
let dataTask = URLSession.shared.dataTask(with: apiUrl) { (data, response, error) in
    guard let data = data, error == nil else {
        print("no data")
    }
    let jsonResult = try! JSONSerialization.jsonObject(with: data, options: []) as! [String: Any]
    print(jsonResult["value"])
}
dataTask.resume()
Comment

PREVIOUS NEXT
Code Example
Swift :: tableview cell animation swift 
Swift :: ios swift create new background thread 
Swift :: swift print 
Swift :: swift uitableview insert cell 
Swift :: dismiss keyboard when tap outside swift 5 
Swift :: string index in swift 
Swift :: create class swift 
Swift :: get height of navigation bar swift 
Swift :: uibutton swift set title color 
Swift :: check enumatted arrray last item swift 
Swift :: swift 5 make image fit uiimageview 
Swift :: swiftui change form section color 
Swift :: uitextview text alignment 
Swift :: socket io swift 
Swift :: type String and int swift addition 
Swift :: uitableview bottom inset 
Swift :: Single Line Comment 
Swift :: toggle button swift 
Swift :: swifter apply progress bar 
Swift :: Swift Syntax of guard Statement 
Swift :: Swift for Loop with where Clause 
Swift :: check google ads sdk version swift 
Swift :: swift singleton 
Swift :: list header swiftui 
Swift :: swift chuck array in peases 
Swift :: how to change the tint color of tab bar on storyboard swift 
Swift :: Error with preview @FocusState SwiftUI 
Swift :: AMAZONCONNECT 
Swift :: swift class init 
Ruby :: see all rails routes in browser 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =