How to use Generics in Swift?

You may confuse or in fear of to use of Generics in Swift. Today we will see, How to use Generics in Swift. Swift Generics allow you to write generic code. Generic code allows us to write reusable code and also we can avoid redundancy of code throughout the project, generic programming allows us to write code once and very clean and in abstracted manners. if you think writing generic code sounds very complicated in terms of implementation. you have wrong assumptions. generics are a compelling feature in swift. By using generics in code we can reusable code and Generic …

Read moreHow to use Generics in Swift?

Enums in Swift

An enumeration type appears in every programming language, Enum stores the finite set of data like string, integer, enum is a list of comprehensive raw data in swift, enum is useful for handling flag, states, choices with respect of object and functionality. enum type plays a very important role in development to handle the lifecycle of operations and many more. let us see, how enum works in swift, enum is declared by enum keyword, with enum type variable name, by using case keyword you can define values in the enum, here is how enum is declared in swift. StatusType enum …

Read moreEnums in Swift

Difference between Swift and Objective – c

If you are still stuck with objective-c, please read this article. In 2014 Apple released a new programming language called Swift, You might have a question in your mind why apple introduced a new programming language, even objective-c was fulfilling all requirements of developers. There are many reasons like Objective C is an old age programming language in terms of architecture and frameworks built in it. Objective C was designed and developed for developing MAC OS applications, Not for new generation hardware like iPhone, iPad, Apple Watch, Swift is designed to keep those devices on priority also. Syntactically and development …

Read moreDifference between Swift and Objective – c

Result In Swift

Apple introduced Result standard library into Swift Codebase in swift 5, Result has enum type, Result represents the outcome of any Operation or Functionality, like calling asynchronous API call, API response may be Success or failure, We can use Result to represent the combination of API Success and Fail. Let us see how Result works, this is how Result defined in Swift library Result returns either success or failure with value. Success type is generic means it could be anything Array of model objects like [Employee] more may be NSData, String, Int, but failure should always conform Error Type. Syntax …

Read moreResult In Swift

How to use @state in SwiftUI

The SwiftUI framework is a reactive framework. No need to use any reactive framework like RxSwift to achieve reactive programming. The @State is a ‘propertyWrapper‘ struct. It wraps a value of property or object with a view at runtime. Did you confused? , Consider below example, fullName variable stated by @State, and then it’s wrapped with TextField view, When you will change the input value of TextField. it will get stored in the fullName property, and yes forgot to say when state value gets changed it will automatically get reflected in UI, wherever you used @State wrapped variable like fullName, …

Read moreHow to use @state in SwiftUI

Lifecycle of UIViewController in Swift / Objective c.

UIViewController is the collection of multiple Views. The view controller manages subview layouts, sizing, interface orientations, and functional implementation. It handles instantiated classes from itself like TableviewController, CollectionViewcontroller, TableViewControllert, UISplitViewControlleretc. It also managing content and handles user interaction events. We can create UIViewController views using three different ways Programmatically, Storyboard, and  Xib’s. The view controller class is the object of UIResponder class and it corresponds to the UIResponder chain. ViewController has a lifecycle for managing view contents, the relationship between subviews, sizing, positioning, Navigation operation between view controllers. UIviewcontroller Lifecycle is performed through following predefined standard functions. 1) ViewDidLoad( ) …

Read moreLifecycle of UIViewController in Swift / Objective c.