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.
Closures are fine, really, and served us well over the years. But we all know that async + closures has its issues.
Let’s just take a look at the following snippet:
We all…
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
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…
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.
Swift Package is a reusable component of Swift, Obj-c, or C++ library…
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.
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…
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. …
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.
Put people in an open field, and ask them, “point me to a location which…
Although we expect String slicing to be a common task in software development, many Swift developers find substring
to be complicated and frustrating.
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]
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…
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.
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.
One of the most useful and…
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.
Of course, we can just push a new view controller whenever the user taps the next button, but with…
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.