Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift convert data to dictionary

do {
let json = try JSONSerialization.jsonObject(with: jsonData, options: [])
}
catch let e{ print(e.localizedDescription) }
Comment

swift convert data to dictionary

do{  
let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String : Any]
}catch{ print("erroMsg") }
Comment

swift string to dictionary

func convertStringToDictionary(text: String) -> [String:AnyObject]? {
    if let data = text.data(using: .utf8) {
        do {
            let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String:AnyObject]
            return json
        } catch {
            print("Something went wrong")
        }
    }
    return nil
}
Comment

PREVIOUS NEXT
Code Example
Swift :: return multiple values from a function swift 
Swift :: swift push view controller 
Swift :: fetch codable from userdefaults ios swift 
Swift :: swiftui list navigation link 
Swift :: swipe to delete xcode 
Swift :: generate random bool swift 
Swift :: how do i get a string from a float swift to 1 decimal swift 
Swift :: swift how to animate constraint change 
Swift :: swiftui console log 
Swift :: swift qrcode scanner 
Swift :: and in swift 
Swift :: sort array alphabetically swift 4 
Swift :: swift 5 get current date date 
Swift :: go to view controller programmatically swift 
Swift :: change font swiftui 
Swift :: swift dictionary contains key 
Swift :: swift dictionary get key from valye 
Swift :: swift file size from url 
Swift :: swift struct 
Swift :: date format swift 
Swift :: swift extension Array of type 
Swift :: sort list ios swift 
Swift :: swift array map example 
Swift :: Swift Syntax of guard Statement 
Swift :: Create enum of Errors Swift 
Swift :: Save and Load Data From Keychain ios swift 
Swift :: swift array chunks 
Swift :: Initializer Swift 
Swift :: Swift Protocol To Calculate Area 
Swift :: ns transport swift code 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =