1.Open Access Used primarily in frameworks to allow subclassing and overriding outside the module 2.Public Access Allows usage outside the module but does not allow subclassing or overriding outside the module. 3.Internal Access Accessible anywhere within the same module. 4.Fileprivate Access Limits access to the enclosing declaration or extensions within …
Automatic Reference Counting
Swift uses Automatic Reference Counting (ARC) to manage the memory of instances of classes. ARC automatically keeps track of references to class instances and deallocates them when they are no longer needed, freeing up memory. Retail Cycle and Memory Leak A retain cycle occurs when two or more class instances …
Initializer
An initializer is a special method that prepares an instance of a class, structure, or enumeration for use. Initializers set up the initial state of an object by assigning values to its properties and performing any required setup. Types of Initializers 1. Designated Initializer 2. Convenience Initializer 3. Failable Initializer …
Class
Classes are reference types used to define reusable and flexible blueprints for objects. Classes can have properties, methods, initialisers, deinitialisers and can conform to protocols. They also support inheritance, which makes them powerful for building complex systems. Characteristic of Class Initialiser(Constructor) Classes can have multiple initialisers, and these can be …