Play With Code: Binary Search in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:42 am | 4-min read

Binary search is a simple algorithm that lets you search an array for a specific value. It’s trivial to implement in Swift, which makes it exceptionally helpful for beginners as an introduction into algorithms. And it’s also a lot of fun! In this tutorial, we’re going to code a binary search algorithm from scratch in Swift. It’s good practice, and we’ll learn some interesting tidbits about Swift along the way. Ready? Let’s go. Finding a Value in an Array of Integers Imagine [...]

Read More

Enums in Swift Explained

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:42 am | 4-min read

With Swift’s enums, also known as enumerations, you can organize groups of values that are related. They’re perfect for managing state in your app, and you can use them in a type-safe way in your code. And that’s not everything: with associated values and raw values you can structure, manage and pass around bits of information in your code with little overhead or syntax! In this tutorial, you learn: How you can use enums in your own Swift code Why enums are so useful, and practic [...]

Read More

Getting Started With Realm Database In Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:42 am | 5-min read

Realm is an easy-to-use database framework for iOS and Swift. In this tutorial, you’ll learn how to get started with Realm Database in your own iOS app projects. We’ll discuss how Realm works, how you can use it in your iOS projects to save and retrieve data, and how Realm is different from the more conventional database tools for iOS. Realm is a powerhouse when it comes to managing databases, and as you’ll see, it’s convenient to use together with Swift. It’s an especially fine [...]

Read More

How To Find Strings with Regular Expressions in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:42 am | 5-min read

How do you use regular expressions in Swift? In this tutorial, you’ll learn how to find strings of text with regular expression. We’ll work our way from problem to solution. Instead of giving you a ready-made code example, I’ll walk you through coding it on your own. When you’re coding your app from scratch, you’ll need to write your own bits of code. You can find tutorials of what you’re trying to accomplish on Google, but what if your code needs to be more complex than that? [...]

Read More

Convert String to Int (and Back) in Swift

Aasif
By Aasif | Last Updated on December 22nd, 2021 6:42 am | 3-min read

How do you convert a String to an Int? The Swift programming language is strong-typed, and that means you can’t type cast between types that aren’t related. Fortunately, many of Swift’s types can be converted from and to strings. Let’s find out how! Here’s what we’ll get into in this tutorial: How to convert from String to Int How to convert from Int to String How to use the printf-style String(format:) Table of Contents Convert String to Int in Swift Convert Int t [...]

Read More

Most Popular Posts