Photo by Danielle MacInnes on Unsplash

Hi iOS Developers,

I’m guessing we have all experienced the pain of spending a lot of time implementing a function, only to realize later that Swift has a built-in function that does the same thing. In this article, I will talk about a few useful protocols that can save you much time and take your code to the next level.

1. CaseIterable

The CaseIterable protocol allows you to retrieve all the values of the type. Let’s take a look at an example:

Without CaseIterable:

enum City {
case new_york
case bei_jing
case vancouver
....
}
let cities: [City] = [.new_york, .bei_jing, .vancouver…


Photo by Jon Tyson on Unsplash

Hi iOS Developers,

In one of my previous articles, I discussed some powerful protocols to take your code to the next level. Today, I’m going to tell you about some handy keywords to streamline your code. Please check out my previous article if you are interested, Long story short, let’s jump right into it.

fallthrough

In general, the switch statement only executes one case. If we want to continue the execution to the next case, we can use the fallthrough keyword. Here’s an example:

Let’s say we’re developing a weather app. We need to check the authorization status. …


Photo by Ridham Nagralawala on Unsplash

Hi

In WWDC 2021, Apple introduced async functions to Swift 5.5. Async functions allow us to run complex tasks asynchronously, just like some other programming languages, such as JavaScript. Asynchronous functions must be defined with the async keyword, to call asynchronous functions, we need to use the await keyword.

Why do we need asynchronous functions?

Our apps work perfectly fine without asynchronous functions, but why do we need them? Commonly, when we are making requests to fetch, push or delete data, we use completion handlers to handle results. If one request needs to be made after another one is completed, we need to put the second…


Photo by Aleksander Vlad on Unsplash

Hi,

SwiftUI is all about states. Common property wrappers are State, EnvironmentObject, AppStorage, StateObject and ObservedObject, etc. Views in SwiftUI are structs. Structs aren't designed to be mutatable. Initially, once a view is rendered, it won’t be changed. But, in most cases, views contain dynamic data. They will be updated accordingly. By adding these property wrappers, SwiftUI creates observers for the properties. If the value of the properties is changed, the drawing system will re-draw the appearance of the view.

For example,

text is a dynamic value, by attaching State to the front, the drawing system will update the…


Photo by Kenny Orr on Unsplash

Hi,

From the feedback I’ve gotten already, it looks like readers really liked my previous story, Swift 5: UIKit is Dying-Part 1. People are afraid of changes. When Swift first came out, people didn’t believe in it. People are generally fearful of change. But now, after a few years, everyone is using Swift. Similarly, when SwiftUI came out, many people were still sticking with UIKit. But trust me, in a year or two, everyone will be using SwiftUI. The earlier you make that move, the more competitive you will be. Today, I’m going to continue telling more about this topic.

List


Photo by Michael Förtsch on Unsplash

Hi iOS Developers,

SwiftUI 3.0 is right around the corner. Among the many cool features, Apple recently added, it is apparent that SwiftUI is going to eliminate the need to use UIKit. Of course, SwiftUI is still in its early stages, so it may still take some time for it to catch up to UIKit. But today, we are going to talk about the advantages of building apps with SwiftUI, and how much time SwiftUI can save us. UIKit may be able to survive for a few years, but SwiftUI is definitely the wave of the future.

Gestures

Adding gestures to…


Photo by Markus Spiske on Unsplash

Hey iOS developers,

Are you working on multiple projects? Do you write repetitive code across different projects? For example, each of your apps may have a sign-in and sign-up page, Settings page or messaging page, etc. The UIs may vary but the logic behind the scene can be very similar. To avoid the pain of going through each app to update the logic or fix bugs, Swift packages are handy tools.

Create a Swift Package

Open Xcode -> Create a new Xcode project -> Select Swift Package.


Photo by Becca Tapert on Unsplash

Hi iOS developers,

Data Structures are containers that are used to organize and store data in the computer so that we can efficiently perform operations. They are the most fundamental components of programming. The best known and most used data structures are Array, Stacks, and Queues, among others. Today, I’m going to talk about another useful Data Structure — Linked List. Unfortunately, Swift doesn’t provide built-in Linked List structures, so we need to build our own.

What are Singly Linked Lists?


by Apple on https://developer.apple.com/wwdc21/

Hey Apple Users/Developers,

WWDC 2021 HAS BEGUN. I’m super excited about all the new features Apple has developed. As a package, these features really take the user experience of Apple products to a whole new level. We’re talking about photodetection, auto-translation, notification summary, and many more. If you missed the WWDC 2021 live show, no worries. I got you. Note takers are money takers. I took the notes for you. If you are an Apple user and are excited about what cool features Apple is introducing, or if you are an iOS developer and wondering about what new features you…

Dylan Chen

iOS Engineer at Lunchbox Technologies. Buy me a coffee at: https://www.buymeacoffee.com/dylancfe15

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