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. …


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…


Photo by Alyssa Stevenson on Unsplash

Hi iOS Developers,

SwiftUI is changing the game. It simplifies the process of building complex and attractive UIs. SwiftUI 3.0 is just around the corner. If you don’t already know about SwiftUI and you don’t want to fall behind, you should definitely check it out. In terms of its architecture, SwiftUI is way different from UIKit. In this story, I am going to tell you about the life cycles in SwiftUI.

If you’ve not followed me, please hit the “follow” button.

App Entry

In SwiftUI, to specify the entry point of the application, we need to add the @main attribute to a…


Photo by Farzad Nazifi on Unsplash

Hi Junior iOS Developers,

“Your code works, but it doesn’t make sense.” You may have heard this from a senior developer. If you are coming from a low-level programming language or you just started learning Swift, this story should be beneficial for you. In this story, we’ll talk about some readability issues. The code should work perfectly fine but just doesn’t make sense.

There are multiple ways to check if an element exists in an array. Here are my suggestions for some common cases.

To check if names contains “Mike”:

let names = ["Dylan", "Jenny", "Amy", "Mike", "Jenny"]

Contains Over Filter Count

// Not…


Photo by Sam Dan Truong on Unsplash

Hi iOS Developers,

Building apps is very time-consuming. Knowing the tool to use is critical. Xcode is a great tool that has a lot of built-in features that help developers save lots of time. Today, we are going to talk about some of the great Xcode features you might not be aware of. Let’s get started!

Snippets

Sometimes, we need to write reusable code in multiple places. Copy and paste are great shortcuts for that but aren’t very efficient. Xcode Snippets allows us to create reusable code snippets that can easily be added to the code.


Photo by lalo Hernandez on Unsplash

Hi iOS Developers,

Building a complex app can take as much time as we might otherwise take to build a small house. Those of you who have done this know that I’m not exaggerating. So finding ways to save time and build the app in a more efficient way is important. One way to save a lot of time is to Integrate with third-party libraries to write cleaner code. Today, I’m going to talk about some popular third-party Swift libraries you can access that can accelerate our development speed.

SwifterSwift

Although Swift provides a lot of built-in functions and properties, often…


Photo by Mihály Köles on Unsplash

Hi iOS Developers,

Swift has a lot of built-in data structures that allow the program to store a collection of data, such as Array and Set. These two are great, they are very easy to use and have a lot of useful built-in functions and properties. But they are not safe. The elements in Arrays and Sets are randomly accessible. Anyone can access any element at any time, which is insecure in some situations. Here’s where Stack and Queue come in to play.

Unfortunately, Swift doesn’t provide built-in data structures for Stack and Queue, so we need to do that…


Photo by Hannah Tasker on Unsplash

Hi developers,

Reactive programming is getting more and more attention since Apple announced its Combine framework. Unfortunately, however, the Combine framework is only available for iOS 13.0+. In the meantime, we can still install the RxSwift framework. But the RxSwift framework is huge. It may increase the size of the app unnecessarily, especially if we are only using it to accomplish some simple tasks. Here’s when Key-Value Observing comes into play.

In this tutorial, we are going to build a reactive application using Key-Value Observing. …

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