A variable is a named storage for data that can change during program execution.
Use the 'let' keyword to declare a constant.
'var' declares a variable, while 'let' declares a constant.
Use the 'func' keyword followed by the function name and parameters.
An optional is a type that can hold a value or 'nil'.
Use 'if let' or 'guard let' to safely unwrap an optional.
Swift can automatically determine the type of a variable or constant.
Use square brackets to define an array, e.g., [1, 2, 3].
A tuple groups multiple values into a single compound value.
Use 'do-catch' blocks to handle errors.
Closures are self-contained blocks of functionality that can be passed around and used in your code.
Classes are reference types, while structs are value types.
Use the 'protocol' keyword to define a protocol and adopt it in a class, struct, or enum.
The 'lazy' keyword is used to delay the initialization of a property until it is accessed.
Define multiple methods with the same name but different parameter types or counts.
'weak' references can become nil, while 'unowned' references cannot.
Generics allow you to write flexible and reusable code by defining placeholders for types.
The 'defer' statement is used to execute code just before the current scope exits.
Define an 'init' method in your class or struct.
'map' transforms elements, 'filter' selects elements, and 'reduce' combines elements.
Swift uses Automatic Reference Counting (ARC) to manage memory.
A computed property calculates its value rather than storing it directly.
Use the 'subscript' keyword to define a subscript for accessing elements in a collection.
They allow you to observe and respond to changes in a property's value.
Use the 'extension' keyword to add functionality to an existing type.
It defines a placeholder type to be specified when the protocol is adopted.
Return 'self' from methods to allow chaining calls.
'Escaping' closures can outlive the function scope, while 'non-escaping' cannot.
Use the 'operator' keyword to define a custom operator.
It enables Objective-C dynamic dispatch for properties or methods.
Pass dependencies through initializers or properties.
'Convenience' initializers are secondary, while 'required' ensures subclass implementation.
Use GCD (Grand Central Dispatch) or locks to manage concurrent access.
It automatically wraps an expression in a closure.
Use the 'observe' method or '@objc dynamic' properties.
'Any' represents any type, while 'AnyObject' represents any class type.
Use a static constant within a class to create a shared instance.
It represents success or failure of an operation with associated values.
Define a struct or class with '@propertyWrapper' to add custom behavior to properties.
'is' checks type compatibility, while 'as' performs type casting.
It indicates that a closure can outlive the function it was passed to.
Structs are value types, while classes are reference types.
It prevents subclassing or method overriding.
'override' is used to indicate method overriding, while 'override func' specifies the method being overridden.
It exposes Swift code to Objective-C runtime.
'public' is accessible everywhere, 'private' is accessible within the same file, and 'fileprivate' is accessible within the same file but outside the class.
It defines type-level properties or methods.
'static' is used for value types, while 'class' is used for reference types.
'weak' references do not increase the reference count, while 'strong' references do.
'throw' is used to throw an error, while 'throws' indicates that a function can throw an error.