Tag Archives: Swift

Styling swiftUI text views with fonts, colors, line spacing and more

By | July 10, 2024

A text view draws a string in your app’s user interface using a body font that’s appropriate for the current platform. You can choose a different standard font, like title or caption, using the font(_:) view modifier. Text views give us predictably wide range of controls in terms of how they look. They are also designed to work seamlessly alongside core apple… Read More »

How do I implement pull to refresh in SwiftUI?

By | June 11, 2024

There are two main approaches to implementing pull-to-refresh functionality in SwiftUI, depending on your SwiftUI version and desired level of customization: 1. Using the built-in refreshable modifier (iOS 16+) If you’re targeting iOS 16 and above, SwiftUI offers a built-in refreshable modifier that simplifies pull-to-refresh functionality for List and ScrollView. Here’s how to use it:… Read More »

Core data stack in swift

By | April 28, 2024

In Swift, Core Data is a powerful framework provided by Apple for managing the model layer objects in an application. A Core Data stack refers to the set of objects and configurations used to interact with the Core Data framework. The Core Data stack typically consists of three main components: 2. Persistent Store Coordinator (PSC):… Read More »

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 »