ons_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
Grokking Swift Updated for Xcode 15 & Swift 5
50 Interview
iOS
Questions & Answers
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E
,ons_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
This resource is crafted to give you a taste of what
to expect in the Grokking the iOS Interview book.
If you find value in this free edition, we highly
recommend checking out the full book at
https://grokkingswift.gumroad.com/l/bsbwhj
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E
,ons_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
1 - Describe the differences between structs and classes in
Swift. When would you choose one over the other?
Purpose: Evaluates the candidate's grasp of Swift's type system and their ability to
choose the appropriate data structure based on value semantics vs. reference
semantics, among other factors.
In Swift, both structs and classes are used to define properties and methods to add
functionality. However, there are key differences in how they are used, which stem from
Swift's value type (struct) versus reference type (class) distinction. Understanding these
differences is crucial for making informed decisions about when to use each in your iOS
applications.
Differences Between Structs and Classes
1. Value vs. Reference Semantics: The primary difference lies in how they are stored and
passed around. Structs are value types, meaning that when you assign a struct to a
variable or pass it to a function, a copy of the struct is created. Classes, on the other hand,
are reference types. When you assign a class instance to a variable or pass it to a function,
you are passing a reference to the same instance, not creating a new one.
2. Inheritance: Classes support inheritance, allowing one class to inherit the
characteristics of another. This is a cornerstone of object-oriented programming,
facilitating code reuse and polymorphism. Structs do not support inheritance.
3. Deinitializers: Classes can have deinitializers, which are called when an instance of the
class is about to be deallocated. Structs do not have deinitializers because their instances
are deallocated automatically once they are no longer needed, without the need for
additional cleanup.
GrokkingSwift 1
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E
,ons_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
4. Memory Management: Classes use reference counting (ARC) for memory management.
Swift keeps track of how many references exist to each class instance and deallocates
instances when there are no more references. Structs, being value types, do not require
reference counting because each copy is independent, and Swift manages their memory
automatically.
5. Type Casting: With classes, you can use type casting to check and interpret the type of a
class instance at runtime. This is useful in conjunction with inheritance. Structs, lacking
inheritance, do not support this kind of runtime type checking.
6. Mutability: Classes are mutable by default. The properties of a class instance can be
changed even when the instance is assigned to a constant. If a struct instance is assigned
to a constant, none of its properties can be changed. There is one exception when you
mark the method as mutating. Swift creates a new instance of that type with the updated
values and assigns it back to the original variable. This is why you can't call a mutating
method on a constant (let) instance of a struct, as constants cannot be reassigned.
7. Automatic Memberwise Initializers: Structs automatically receive a memberwise
initializer if you don’t define any custom initializers. Memberwise initializer is not
available for classes, you have to explicitly define one.
8. Performance: Instances of classes are allocated on the heap while instances of structs
are typically allocated on the stack. Heap allocation is more complex and slower than
stack allocation due to the dynamic nature of heap memory management. In addition,
Swift uses an optimization called copy-on-write for structs. When a struct is copied, the
actual data is not immediately copied. Instead, both instances share the data until one of
them modifies it, at which point a real copy is made. This makes passing structs around
very efficient in terms of memory.
GrokkingSwift 2
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
Grokking Swift Updated for Xcode 15 & Swift 5
50 Interview
iOS
Questions & Answers
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E
,ons_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
This resource is crafted to give you a taste of what
to expect in the Grokking the iOS Interview book.
If you find value in this free edition, we highly
recommend checking out the full book at
https://grokkingswift.gumroad.com/l/bsbwhj
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E
,ons_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
1 - Describe the differences between structs and classes in
Swift. When would you choose one over the other?
Purpose: Evaluates the candidate's grasp of Swift's type system and their ability to
choose the appropriate data structure based on value semantics vs. reference
semantics, among other factors.
In Swift, both structs and classes are used to define properties and methods to add
functionality. However, there are key differences in how they are used, which stem from
Swift's value type (struct) versus reference type (class) distinction. Understanding these
differences is crucial for making informed decisions about when to use each in your iOS
applications.
Differences Between Structs and Classes
1. Value vs. Reference Semantics: The primary difference lies in how they are stored and
passed around. Structs are value types, meaning that when you assign a struct to a
variable or pass it to a function, a copy of the struct is created. Classes, on the other hand,
are reference types. When you assign a class instance to a variable or pass it to a function,
you are passing a reference to the same instance, not creating a new one.
2. Inheritance: Classes support inheritance, allowing one class to inherit the
characteristics of another. This is a cornerstone of object-oriented programming,
facilitating code reuse and polymorphism. Structs do not support inheritance.
3. Deinitializers: Classes can have deinitializers, which are called when an instance of the
class is about to be deallocated. Structs do not have deinitializers because their instances
are deallocated automatically once they are no longer needed, without the need for
additional cleanup.
GrokkingSwift 1
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E
,ons_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
9/25/2026, 3:19:07 PM_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf@
4. Memory Management: Classes use reference counting (ARC) for memory management.
Swift keeps track of how many references exist to each class instance and deallocates
instances when there are no more references. Structs, being value types, do not require
reference counting because each copy is independent, and Swift manages their memory
automatically.
5. Type Casting: With classes, you can use type casting to check and interpret the type of a
class instance at runtime. This is useful in conjunction with inheritance. Structs, lacking
inheritance, do not support this kind of runtime type checking.
6. Mutability: Classes are mutable by default. The properties of a class instance can be
changed even when the instance is assigned to a constant. If a struct instance is assigned
to a constant, none of its properties can be changed. There is one exception when you
mark the method as mutating. Swift creates a new instance of that type with the updated
values and assigns it back to the original variable. This is why you can't call a mutating
method on a constant (let) instance of a struct, as constants cannot be reassigned.
7. Automatic Memberwise Initializers: Structs automatically receive a memberwise
initializer if you don’t define any custom initializers. Memberwise initializer is not
available for classes, you have to explicitly define one.
8. Performance: Instances of classes are allocated on the heap while instances of structs
are typically allocated on the stack. Heap allocation is more complex and slower than
stack allocation due to the dynamic nature of heap memory management. In addition,
Swift uses an optimization called copy-on-write for structs. When a struct is copied, the
actual data is not immediately copied. Instead, both instances share the data until one of
them modifies it, at which point a real copy is made. This makes passing structs around
very efficient in terms of memory.
GrokkingSwift 2
s_and_Answers_-_Thien_Liu.pdf@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!
@@@@@@@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@
_OceanofPDF.com_50_Essential_iOS_Interview_Questions_and_Answers_-_Thien_Liu.pdf_OceanofPDF.com_50_E