URLSession in 6 Steps - GET and POST (Swift)

Опубликовано: 12 Август 2019
на канале: Mobile App Mike
9,336
130

In this video, I use Swift's built-in network request handler, URLSession, to retrieve and push data from 2 different sites: https://api.chucknorris.io & https://pastebin.com.

Steps:
1) Get API keys (as needed)
2) Add any needed add’l variables using URLRequest (parameters, headers)
3) Create instance of a URLSession
4) Create dataTask w/ do-catch block for data
5) Serialize and format data (usually of type JSON) into project
6) Error handling [don’t forget .resume()]

Finished project: https://github.com/mgm720/alamo/tree/...

Twitter:   / milesoftweets  
Instagram:   / michaelmilestv