By popular demand, I’m starting a semi-regular series exploring common algorithm questions asked during iOS interviews. Let me know on Twitter if you’d like to see any particular algorithm or coding question answered. In this post, let’s solve the following problem in Swift: Given an array of numbers and another number called sum, find all …
How to add XCFramework to Xcode project
XCFramework is a new code distribution format introduced by Apple in Xcode 11. The new XCFramework bundle type (similar to framework bundle) now allows to support multiple architectures, platforms and simulator in one package. As XCFrameworks are gaining in popularity, iOS developers will need to know how to use them in their projects. This tutorial covers the steps …
How to add missing iPhone SE simulator in Xcode 11 with iOS 13 SDKs
You might have noticed that after upgrading to Xcode 11 with iOS 13 SDKs, Xcode’s list of iOS Simulators to run your app on does not include the iPhone SE simulator any more. The iPhone SE simulator comes very handy because we still need to support this device hence the need to test on it. In this …
How to create and use toggle in SwiftUI
A toggle in SwiftUI is a control which can go between on and off states and it’s equivalent to UISwitch in UIKit. In this tutorial we’re going to learn how to create a toggle and use it in various examples. We’re going to update a view (show/hide an image) based on a toggle state, create custom …
SwiftUI NavigationView tutorial with examples
NavigationView in SwiftUI is a container view which allows you to manage other views in a navigation interface. Learn how to customize navigation bar with a title (large or small), add leading and trailing buttons to the navigation bar, and implement a master-detail flow where you can push detail view on top of the master …
How to build a circular progress bar in SwiftUI
In this tutorial we’re going to learn how to design and build a circular progress bar in SwiftUI using stacks, Circle shapes and view modifiers. The sample app will include a circular progress bar and a button underneath it, which will increment the progress. The final product will look like this: Start by creating a new single …
How to make custom view modifiers in SwiftUI
SwiftUI lets you modify the appearance or behavior of views by applying view modifiers to them. A view modifier takes a given view, modifies it, and returns a brand new view. This is really important to understand. Besides using the existing SwiftUI modifiers, you can create your own view modifier by conforming to the ViewModifier protocol …
How to use switch statement with enum in Swift
Swift language provides a switch statement which allows you to compare a given value against multiple possible matching options and perform respective action. In its simplest form, a switch statement looks and works like that: let frameworkName = “SwiftUI” switch frameworkName { case “UIKit”: print(“Using UIKit”) case “SwiftUI”: print(“Using SwiftUI”) default: print(“Framework undefined”) } Given …
How to present new sheet view from navigationBarItems button in SwiftUI
In this tutorial we’re going to learn how use NavigationView’s navigationBarItems button to present a new sheet view modally. In order to accomplish this, we’re going to follow these steps: Create a NavigationView Add a button to the NavigationView Create a new sheet view which we wish to present Add action to the button to present …
How to expand SwiftUI views to span across entire width or height of screen
Learn how to use frame() modifier to expand SwiftUI views to take full width or height of screen. When applied to your view, the frame() modifier positions it within another view (frame) with specified dimensions. By manipulating the maximum width and/or height of the new frame, we’ll be able to achieve the desired effect of …