Glossary Of Swift Common Terms

Introduction

 
In Swift programming there is so much confusing syntax and functionality, so here I will give a brief introduction for all common terms used in Swift language. 
 
@autoclosure
 
An attribute attached to function parameters that are closures, which asks Swift to silently wrap any code using it in a closure rather than requiring users to do it by hand. This is used rarely, but it's important in the assert() function.
 
@available
 
An attribute attached to types or functions that mark them as being available or unavailable to specific versions of Swift or operating system.
 
@discardableResult
 
An attribute attached to methods that return to value, marking the return value as safe to ignore if the caller wants to. When this is not used, Swift will show a warning If you don't do something with the function's return value.
 
@dynamicCallable
 
An attribute attached to types to mark them as being directly callable, primarily so that Swift can interact more easily with a dynamic language such as Python.
 
@dynamicMemberLookup
 
An attribute attached to types to mark them as being able to handle undefined properties using special methods, primarily so that Swift can interact more easily with dynamic languages such as Python.
 
@escaping
 
An attribute attached to function parameters that are closures, which tells Swift the closure will be used after the function has returned. This will in turn cause Swift to store the closure safely so it doesn't get destroyed prematurely.
 
@objc
 
An attribute used to mark methods and properties that must be accessible to Objective-C code. Swift doesn't make its code accessible to Objective-C by default to avoid making the code larger than it needs to be.
 
@objcMembers
 
An Attribute used to mark classes where all properties and methods must be accessible to Objective-C code. Swift doesn't make code accessible to Objective-C by default to avoid making the code larger than it needs to be.
 
@unknown
 
An Attribute attached to the default case of switch blocks that allows code to handle enum cases that may be added at some point in the future, without breaking source compatibility.
 

ABI

 
ABI stands for Application Binary Interface. At runtime, Swift program binaries interact with other libraries through an ABI. It defines many low-level details for binary entities like how to call functions, how their data is represented in memory, where metadata is and how to access it.
 
Associated type
 
A missing type in a protocol that must be specified by whatever type is conforming to the protocol. Associated types allow us to have flexibility when adding conformances, we can say that to conform to our protocol you must have an array of items, but we don't care what the data type of those items is. Associated types are written as one in Swift is associtedtype 
 
Associated value
 
A value that has been added to an enum case to provide some extra meaning e.g. you might have an enum case saying the weather is windy, then add an associated value saying how windy.
 
Block
 
Block means any chunk of code that starts with {and ends with }("a code of block") but "block" is also the Objective-C name for closures.
 
Capturing values
 
The name for the process of closures keeping a reference to values that are used inside the closure but were created outside. This is different from copying the closure refers to the original values, not it's own copies, so if the original values change then the closure's values change too.
 
CaseIterable
 
A Swift protocol that can be applied to enums. If the enum has cases with no associated values, the compiler will generate an all cases array that lets you loop over the cases in the enum.
 
CGFloat
 
A floating-point number that may be equivalent to a Double or Floats depending on the platform.
 
Class
 
A custom data type that can have one or more properties and one or more methods unlike structs, classes are reference types.
 
Class inheritance
 
The ability for one class to build on another, inheriting all its methods and properties. some languages allow one class to inherit from multiple parents, Swift does not.
 
Closure
 
An anonymous function that automatically keeps a reference to any values it uses that were declared outside the function.
 
Codable
 
A protocol that allows easy conversion between a struct or a class and JSON or XML.
 
Collection
 
A Swift protocol that is used by sequences types you can traverse multiple times without destroying them such as arrays and dictionaries.
 
Comparable
 
A common Swift protocol that says conforming types can be placed into an order using <.
 
Computed properties
 
Any property that doesn't have a storage area for its value, and instead is calculated each time the property is accessed by running some code.
 
Defer
 
A keyword that allows us to schedule work for when the current scope is exited.
 
Deinitializer
 
A special method that is called when an instance of a class is being destroyed. these may not accept parameters and don't exist on structs.
 
Enum
 
An enum defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.
 
Example
  1. enum CompassPoint {  
  2.     case north  
  3.     case south  
  4.     case east  
  5.     case west  
  6. }  
Extension
 
Extension adds new functionality to an existing class, structure, enumeration or protocol type. This includes the ability to extend types for which you do not have access to the original source code.
 
Fallthrough
 
A keyword used in switch blocks mean "carry on executing the case immediatly following this one".
 
Failable initializer
 
An initializer that returns an optional value, because initialization might have failed for some reason. These are written in init?() and init!().
 
Final Class
 
A class that may not be inherited from anything else.
 
Force unwrap
 
The process of using the value inside an optional without checking it exists first. If optional is empty - if it has no value - force unwrapping will crash your code.
 
Guard
 
A piece of Swift syntax that checks whether a condition is true, and force you to exit the current scope immediately if it is not. This is a commonly used guard which checks whether an has a value, and if it does, create new contant for optional's value so it can be used safely. If it has no value, the guard condition fails and you must exist current scope.
 
Hashable
 
A Common Swift protocol that says conforming types can be represented using hash values.
 
Higher-Order function
 
A function that accepts another function as a parameter or sends back a function as its return value.
 
Initializer
 
A special method that gets run to create an instance of structs or class. You can have many initializers, and in the case of classes may call parent initializers inside your own initializer.
 
inout parameters
 
A function parameter that, when changed inside the function, remains changed outside the function.
 

Summary

 
I hope you understood, I will try to explain Swift common terms in Swift programming.
 
If you enjoyed reading my article, please share it and recommed to others. Thank you in advance.
 
Happy programming!!!