Data
Managing data as bytes.
Data
Managing data as bytes.
0
0
Checkbox to mark video as read
Mark as read

We've seen how JSON format works, however in order to send or receive this String (or any other kind of data) through internet, it needs to be converted to an array of bytes which can be represented with the Swift's variable type Data.

We can convert any type of variable to Data and vice versa. In the following example, you can see how we convert a String to Data, which we will later use when working with servers and databases.

let json: String = """
  { "name": "Pablo", "age": 24 }
"""

let jsonData = json.data(using: .utf8)

course

Quiz Time!

0 Comments

Join the community to comment
Sign Up
I have an account
Be the first to comment

Accept Cookies

We use cookies to collect and analyze information on site performance and usage, in order to provide you with better service.

Check our Privacy Policy