Answers for "swift read json from url"

0

swift read json from url

private func readLocalFile(forName name: String) -> Data? {
    do {
        if let bundlePath = Bundle.main.path(forResource: name,
                                             ofType: "json"),
            let jsonData = try String(contentsOfFile: bundlePath).data(using: .utf8) {
            return jsonData
        }
    } catch {
        print(error)
    }
    
    return nil
}
Posted by: Guest on October-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language