Tag Archives: Swift

How to setup a basic core data stack in swift?

By | February 22, 2024

Setting up a Core Data stack in Swift involves several steps, including creating a managed object model, setting up a persistent store coordinator, managed object context, and other components. Here’s a basic guide to setting up a Core Data stack in Swift: Create a Data Model: Generate NSManagedObject Subclasses: Initialize the Persistent Store Coordinator: Managed… Read More »

What is enum associated values in swift?

By | February 15, 2024

In Swift, enumerations (enums) are powerful constructs that allow you to define a group of related values. Associated values in Swift enums enhance their flexibility by enabling each enum case to carry additional data of varying types. This feature allows you to model more complex data structures and behaviors with enums. Here’s how you can… Read More »

What is protocol oriented programming in swift?

By | February 7, 2024

Protocol-oriented programming (POP) is an approach to software development in Swift that emphasizes the use of protocols to define interfaces and behavior, promoting code reuse, flexibility, and composability. POP encourages structuring code around protocols rather than classes, focusing on what types can do rather than what they are. Key concepts of protocol-oriented programming in Swift… Read More »

What is a frame and bounds of a UIView in swift?

By | February 1, 2024

In iOS development using UIKit, a UIView is a fundamental building block for constructing the user interface. Two important properties of a UIView are its frame and bounds. These properties define the size and location of the view within its superview. frame: In this example, myView is positioned at (50, 50) within its superview, and… Read More »

What are the difference between UIKit and SwiftUI in iOS?

By | January 14, 2024

UIKit and SwiftUI are both UI frameworks used in iOS development, but they differ significantly in terms of design, architecture, and development approach. Here are some key differences between UIKit and SwiftUI: 1. Declarative vs Imperative 2. UI Layout 3. Code re-usability 4. Live preview 5. UI Representation 6. State management 7. Adoption and Legacy… Read More »

How data is passed from one view to another in SwiftUI?

By | January 13, 2024

In SwiftUI, you can pass data from one view to another using the @State, @Binding, @ObservedObject, or @EnvironmentObject property wrappers. The appropriate choice depends on the nature of the data and the relationship between the views. Below are brief explanations and examples for each approach: 1. @State : Use @State to store simple values within… Read More »

Setting button actions programatically in Java, Python, JavaScript, SWIFT and Kotlin

By | January 9, 2024

Button action calls for an action when user tap on a button. This may be for making a service call, for doing some calculation or simply just to dismiss a view. Here are the different ways of setting button action in different languages. Java Python (TKinter) JavaScript: Swift Kotlin These examples demonstrate how to set… Read More »

Convert a date from Central Standard Time (CST) to Indian Standard Time (IST)

By | January 2, 2024

To convert a date from Central Standard Time (CST) to Indian Standard Time (IST), you need to consider the time zone difference between these two zones. Below are examples in Swift : Swift: Java: Python: JavaScript: These examples assume a specific date and time format. You should adjust the date format and time zone identifiers… Read More »

Class has not initialiser error in Swift – Solved.

By | August 14, 2017

Apart from other languages, when you write a class in Swift, It should have a initialiser. To solve this we have to write init() function in that particular class. Just like below. For example, look at the below class. Here we have 5 variables. The above error usually comes when you don’t initialize all variables… Read More »

What are optionals in Swift ( ? && ! ).

By | June 30, 2016

Swift introduces Optionals type, which handles the absence of a value. Optionals say if there are set a value, then take that value, it can be of any type AND else it is nil. Basically It has two possible values, None and Some(T), where T is an associated value of the correct data type available… Read More »

Contacts Demo in Swift 2 – Showing Contacts Picker, Load Contacts in Custom TableView, Add New Contact, Update Contact, Delete Contact, Search Contact

By | February 23, 2016

In Today’s post I will show you How to do below things in Swift 2… 1. Show Contact Picker using System In-Built UI & Pick a Contact 2. Load all Contacts in a TableView 3. Search a Contact 4. Add a New Contact 5. Update a Contact 6. Delete a Contact Before using the contacts… Read More »