Protocols in Swift

A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that …

Protocols in Swift Read More »

Collection Types in Swift

Swift provides three primary collection types, known as arrays, sets, and dictionaries, for storing collections of values. Arrays are ordered collections of values. Sets are unordered collections of unique values. Dictionaries are unordered collections of key-value associations.  Arrays An array stores values of the same type in an ordered list. The same value can appear …

Collection Types in Swift Read More »

Features in Swift

Swift programming language is being designed so that developers can write correct programs and maintain them easily. It offers the following features:  Safety: Swift is an efficient way to write programs. Checking code before it is used in production is very important. Apple Swift removes any unsafe code before it is used in production. Simple syntax: Swift’s …

Features in Swift Read More »

Enum in Swift

The term enumeration refers to a user-defined data type consisting of a set of related values that allows you to work with those values in your code in a type-safe manner. An enumerated data type is defined by the keyword enum. Syntax: enum enum_name  {    // enumeration values are described here } Example:  enum MonthsofaYear …

Enum in Swift Read More »

SOLID in example swift

Single Responcibility class Animal { private let name: String init(_ name: String) { self.name = name } func getAnimalName() {} func saveAnimal(_ name: String) {} } It makes two action, getting the animal and saving to somewhere class Animal { private let name: String init(_ name: String) { self.name = name } func getAnimalName() {} …

SOLID in example swift Read More »

Concurrency in Swift

Concurrency means “running multiple tasks simultaneously”. Concurrency allows iOS devices to handle background tasks (such as downloading or processing data) while maintaining a responsive user interface. In iOS, you can manage concurrent tasks using Grand Central Dispatch (or GCD), and Operations (formally known as NSOperation). In order to achieve concurrency, iOS provides three ways as …

Concurrency in Swift Read More »

Structures and Classes in swift

Comparing Structures and Classes Structures and classes in Swift have many things in common. Both can: Define properties to store values Define methods to provide functionality Define subscripts to provide access to their values using subscript syntax Define initializers to set up their initial state Be extended to expand their functionality beyond a default implementation …

Structures and Classes in swift Read More »