Category Archives: Swift

Swift – Class (Part II)

By | 30/03/2022

Swift – Class (Part I) MULTIPLE INITIALIZERS If we run this code, these will be the results: DEINITIALIZERDeinitialization is a process used to deallocate the memory space before a class instance deallocated. The ‘deinit’ keyword is used to deallocate the memory spaces occupied by the system resources. If we run this code, these will be… Read More »

Swift – Struct

By | 09/03/2022

In this post, we will see how to use Struct in Swift.But first of all, what is a Struct?:From Apple web site: “Use structures to represent common kinds of data. Structures in Swift include many features that are limited to classes in other languages: They can include stored properties, computed properties, and methods. Moreover, Swift… Read More »

Swift – Throwing functions

By | 02/03/2022

In this post, we will see how to use Throwing functions to handle errors in our code. We start opening Xcode and we create a Playground file called Errors where, we will define a simple method “Divide” to divide two number greater than 1: If we run the code, this will be the result: The… Read More »

SwiftUI – MVVM

By | 14/07/2021

In this post, we will see how to implement MVVM pattern in SwiftUI.But, what is MVVM pattern?From wikipedia:“Model–view–viewmodel (MVVM) is a software architectural pattern that facilitates the separation of the development of the graphical user interface (the view) – be it via a markup language or GUI code – from the development of the business logic or back-end logic (the model) so that the view is not dependent on any… Read More »

SwiftUI – How to show an Alert

By | 03/02/2021

In this post, we will see how to implement an Alert in SwiftUI. We create a project called AlertTest and add this code in the file ContentView: [CONTENTVIEW.SWIFT] This is all and now, if we run the application, this will be the result:

SwiftUI – Tips for button

By | 13/01/2021

In this post, we will see three tips that might help us to create buttons in our applications. First of all, we open Xcode, we create an iOS project called TestButton and we add three buttons: Then, we create a new Swift file called ButtonStyleCustom where we will define the style that we will use… Read More »