Image for post
Image for post

Imagine that in your iOS app you have a UIWebView that loads an arbitrary URL. There are plenty of malicious sites on the web and let’s say we want to warn our users if they attempt to access a nefarious site. This begs the question: what’s an efficient way of checking if the domain in a URL is known to be a malicious site? …


Image for post
Image for post

Retrieving data from a RESTful web API is a fundamental task in iOS development. Making a network request using the NSData class does not allow for concurrency, as it is a synchronous operation. When we perform network operations we want them to be asynchronous, meaning that we want it to be done in the background, while other important tasks are being performed. The NSURLSession class, and associated methods, enables us to do this.

Before we walk through code, let’s solidify the aforementioned concepts with an analogy: Think of iOS as a highway in the United States with multiple lanes, where each lane is a queue. Furthermore, the cars in each lane are analogous to blocks of executable code, i.e. threads. On a highway, the left lane is typically reserved for faster moving traffic. The “left lane” in iOS is called the main queue and it is reserved for user interface tasks, such as when a user taps a button or scrolls on a table view. …

About

Nathan Krishnan

Breaking apart technical ideas and concepts into palatable morsels. http://nathankrishnan.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store