And you are going to love them

Stairway
Stairway
Photo by Wesley Pribadi on Unsplash.

Old iOS developers remember the days when Objective C didn’t support blocks just yet. Async operations were a nightmare.

Blocks improved async operations, and when Swift appeared, closures were already natural for us. But to help us get through async calls, closures still have their pitfalls.

Fortunately, a new feature called the async function is coming to Swift, and it will make our lives much better.

What’s the Problem With Closures?

Closures are fine, really, and served us well over the years. But we all know that async + closures has its issues.

Pyramid of Doom

Let’s just take a look at the following snippet:

We all…


UICollectionView and UIViewControllerTransitionDelegate can teach us a lot on how to design a significant separation in our code

Introduction

UICollectionView and UIViewControllerTransitionDelegate are with us for a long time already. Both of them solved some critical issues iOS development had with flexibility and customization of user experience.

What’s more interesting is that both of them provide a great example of how to create a flexible design pattern that lets us do almost anything we can imagine

To understand that, we need to go back many years in history.

How many years? Well, we’re talking about the year 2012. In terms of mobile development, it means ancient history.

The only collection UI element we, iOS developers, had, is UITableView.

UITableView is an excellent component that helps us display a list of items…


You can now add resources to your swift packages in Xcode 12. What does it mean?

Introduction

In one of my previous articles, I mentioned how SPM (Swift Package Manager) changed the way I build and maintain my Code. I praised the deep integration Xcode 11 has with Swift Packages and how easy it is to create a tremendous modular Code.

But this “heaven” is not perfect; one thing was missing — The ability to add files to a Swift Package other than Code. You cannot add images, data files, or even a storyboard.

Fortunately, Apple made some changes in Swift 5.3 and Xcode 12.

Wait. Swift Package…remind me?

Swift Package is a reusable component of Swift, Obj-c, or C++ library…


Better collection views with backwards compatibility

Yes, you can still support old phones. (Photo by Bagus Hernawan on Unsplash.)

Introduction

If you make heavy use of tables and collection views, iOS 13 brought something great for you — DiffableDataSource. If you’re not familiar with it, you’re more than welcome to read my (excellent!) tutorial about how to implement it into your project.

Anyway, in short — DiffableDataSource is a way to refresh your collections, while all the dirty calculations of insert/delete/update are done for you by UIKit.

Sounds Great, What’s the Catch?

DiffableDataSource requires iOS 13. That’s the problem.

Collections (when I say collection, I mean UITableView or UICollectionView) are a central component in our apps, and you can’t ignore iOS 12 users by just…


Creating packages in your app is almost as easy as adding new folders

Photo by Martin on Unsplash

Introduction

Even though we’ve had dependency managers for several years now, with Swift Package Manager (SPM), creating packages in your app is almost as easy as adding new folders. Converting parts of your project to packages is not just a way to organize your code nicely; it actually changes the way you work and architect your app.

It all started when I had to take an existing big project and port one feature to a dedicated app. …


Intro

No doubt, navigation apps have changed our lives. We can hardly remember the days when we used to print maps or ask a passerby for directions. Heck, tell that to our kids, and they will think we lived in the stone age.

Navigation apps went a long way in improving their interface and features, starting from better ETA estimation, through live updates and ending with updated map data.

Now I think it’s time for navigation apps to leverage their user experience to the next level.

Moving from distance to time

Put people in an open field, and ask them, “point me to a location which…


A look at what happens when you break down a String

Photo by Pro Church Media on Unsplash

Notes

Although we expect String slicing to be a common task in software development, many Swift developers find substring to be complicated and frustrating.

Comparing Substring in Other Languages

Let’s see how substring works in other computer languages:

C++: str.substr(2,8)
Java: str.substring(2,8)
Python: str[2,8]
Objective-C: [str substringWithRange:NSMakeRange(2,6)]

Now let’s see how substring works in Swift:

var startIndex = str.index(str.startIndex, offsetBy: 2)
var endIndex = str.index(startIndex, offsetBy: 6)
var substring = str[startIndex..<endIndex]

The Root of the Problem — UTF-8

To understand how Strings work, we need to go back to the basics — Unicode and UTF-8.

When we work with Strings, we have the feeling we are dealing with a plain text, just an…


Photo by Mikhail Vasilyev on Unsplash

Notes

Developers spend a lot of time fixing bugs or, in other words, debugging. In fact, sometimes we spend more time fixing bugs than actually developing new features. As a result, debugging skills are crucial for your success as a developer, and in the following articles, we will try to leverage our debugging skills by learning about the tools xCode provides us.

What is LLDB?

A low-level debugger (LLDB) is the default debugger used in Xcode and is part of the LLVM project. LLDB replaced GDB in XCode 5 and has several advantages, such as performance and scriptability.

Evaluate Code in Your Console With Expression

One of the most useful and…


Ways to make the onboarding process easy for users

Photo by Jon Tyson on Unsplash

What Is Onboarding?

App onboarding is the phase when the user first engages with your app, learns how to use it, and does the first setup so they can start enjoying your creation.

For us developers, this is not that trivial — we’re used to architecture when every screen decides what’s the next screen to open. In onboarding, the logic of what’s on the next screen has nothing to do with the current screen. That’s what makes it a different creature in our project.

What Do We Want From Our Onboarding Process?

Of course, we can just push a new view controller whenever the user taps the next button, but with…


Increase your app presence with very little effort

Photo by Samuel Zeller on Unsplash

Why Is Implementing Search API’s Important?

Most of the apps contain content, either created by the user or created by the app itself. iOS contains a great search engine called Spotlight, which plays the role of Google on your device.

Spotlight searches your device content, apps, and even websites. Making your app content exist in Spotlight is very easy and can expose your content, even for users that don’t have your app installed.

Avi Tsadok

Head of Mobile Any.do, Author of “Pro iOS Testing”

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