Networking with URLSession - Part 1: Introduction | Ray Wenderlich

Hi Audrey,

I really appreciate finding your tutorials here. They have been very helpful.

I wonder if you could advise me on my app. I have used hidden WKWebView objects to start URL downloads (via load()), which run on the main thread. Then I would inject a Javascript script to scan the DOM I get and send messages to a delegate object of my own design to capture the data of interest to me. This has worked fine for me, but as I now need to download many pages at a time for category parsing, I’ve noticed how the UI will block (thanks to your Concurrency Tutorial for insights on this!).

My question is whether I can use my existing architecture with URLSession, or whether I need to scrap the Javascript parsing and get some kind of HTML Parser library for Swift instead. I suspect that the URLSession design really isn’t setup to manage script injection. Am I right?

Thanks for any insights you can provide.
Best regards,

Mike Mehr

hi Mike: sorry, I’ve never done anything so exotic :grin:

I wrote a tutorial on CloudKit JS, but that’s Apple providing JS to access the CloudKit API.

I’m sure there are good HTML parsers in Swift, somewhere on GitHub or similar.

Thanks, Audrey. I’ll go look for a few of those libraries then instead and rewrite my exotic app using something a bit more standard so I can capitalize on the background behavior. Being a lone programmer, I sometimes forget that solutions that I devise from reading the Apple docs really aren’t the accepted way of doing things. It just seemed to be the way to make things work at the time I was looking into this (late 2014 thru 2015).
Regards,
Mike

1 Like

Hi @audrey,

I really love your courses. Your explanation is always great making complicated matters so simple. Keep up the good work!

Cheers!

1 Like

hi @audrey , Thanks for your great video tutorial. I really want to understand about networking. is there any prerequisite course that I should watch before I watch this course about Networking with URL Session? this is the first section that i watch in RayWenderlich.

my education background is actually chemical engineering, so…I don’t know, I am not really comfortable to study about this topic. maybe you could give me suggestion what topic that I study first ? I am a beginner in iOS development, i understand about basic and intermediate swift. but when I follow other tutorials that needs networking and concurrency, i feel bad,
because i just copy the code, I don’t really grasp about it, I want to understand. Thanks Audrey, I hope you understand my confusion :see_no_evil: :grin:

hi! if you’re familiar with Swift, and comfortable with writing completion handlers, you should be fine with this course. I was the same, before taking on this video course — I only knew how to copy-paste-edit the simplest URLSession task. When I started updating the original course, I was amazed how much more there was to networking!

If you want a quick look, you could work through this tutorial first:

https://www.raywenderlich.com/158106/urlsession-tutorial-getting-started

It builds a version of the same HalfTunes app that this course uses.

There’s an updated version (Xcode 9, iOS 11, Swift 4) of this course that should be appearing soon — mainly JSON parsing and some new background/continuity features.