├── .gitignore ├── Delegate Protocol ├── Cheat Sheet │ └── Cheat Sheet.md ├── Interview Questions │ └── Interview Questions.md └── README.md ├── Filter, Map, Reduce ├── Cheat Sheet │ └── Cheat Sheet.md ├── README.md └── Interview Questions │ └── Interview Questions.md ├── Gesture Recognizer ├── Cheat Sheet │ └── Cheat Sheet.md └── README.md ├── Error handling, do, try, catch ├── Cheat Sheet │ └── Cheat Sheet.md ├── Interview Questions │ └── Interview Questions.md └── README.md ├── Observer & Notification Pattern ├── Cheat Sheet │ └── Cheat Sheet.md ├── Interview Questions │ └── Interview Questions.md └── README.md ├── Unwrapping optional ├── README.md ├── Interview Questions │ └── Interview Questions.md └── Cheat Sheet │ ├── If let.swift │ ├── guard let.swift │ ├── optional chaining.swift │ └── force unwrap.swift ├── Bounds vs. Frame ├── Interview Questions │ └── Interview Questions.md ├── Cheat Sheet │ └── Cheat Sheet.md └── README.md ├── Classes & structures ├── Interview Questions │ └── Interview Questions.md ├── README.md └── Cheat Sheet │ └── Classes and Struct.swift ├── Concurrency and Threading ├── Interview Questions │ └── Interview Questions.md ├── README.md └── Cheat Sheet │ ├── What is concurrency.md │ └── What are Queues.md ├── Retain Cycle, Automatic Reference Counting, Memory Leak ├── Interview Questions │ └── Interview Questions.md ├── Cheat Sheet │ └── Cheat Sheet.md └── README.md ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /Delegate Protocol/Cheat Sheet/Cheat Sheet.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Filter, Map, Reduce/Cheat Sheet/Cheat Sheet.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Gesture Recognizer/Cheat Sheet/Cheat Sheet.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Error handling, do, try, catch/Cheat Sheet/Cheat Sheet.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Filter, Map, Reduce/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Filter, Map, Reduce 3 | -------------------------------------------------------------------------------- /Gesture Recognizer/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Gesture Recognizer 3 | -------------------------------------------------------------------------------- /Observer & Notification Pattern/Cheat Sheet/Cheat Sheet.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unwrapping optional/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Unwrapping optional 3 | -------------------------------------------------------------------------------- /Bounds vs. Frame/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Delegate Protocol/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Filter, Map, Reduce/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Unwrapping optional/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Classes & structures /Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Concurrency and Threading/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Error handling, do, try, catch/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Error handling, do, try, catch/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Error handling, do, try, catch 3 | -------------------------------------------------------------------------------- /Observer & Notification Pattern/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Observer & Notification Pattern/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Observer & Notification Pattern 3 | -------------------------------------------------------------------------------- /Retain Cycle, Automatic Reference Counting, Memory Leak/Interview Questions/Interview Questions.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Retain Cycle, Automatic Reference Counting, Memory Leak/Cheat Sheet/Cheat Sheet.md: -------------------------------------------------------------------------------- 1 | 2 | ## Error handling, do, try, catch 3 | -------------------------------------------------------------------------------- /Retain Cycle, Automatic Reference Counting, Memory Leak/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Retain Cycle, Automatic Reference Counting, Memory Leak 3 | -------------------------------------------------------------------------------- /Bounds vs. Frame/Cheat Sheet/Cheat Sheet.md: -------------------------------------------------------------------------------- 1 | # Bounds vs Frame 2 | 3 | ![Bounds vs Frame](https://user-images.githubusercontent.com/89042174/171762772-c21598e8-ae64-41c4-8937-d7a4eced42f8.jpg) 4 | -------------------------------------------------------------------------------- /Bounds vs. Frame/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Bounds vs. Frame 3 | 4 | ## [Cheat Sheet](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Bounds%20vs.%20Frame/Cheat%20Sheet) 5 | 6 | ## [Q&A](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Bounds%20vs.%20Frame/Interview%20Questions) 7 | -------------------------------------------------------------------------------- /Delegate Protocol/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Delegate Protocol 3 | 4 | ### [Cheat sheet](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Delegate%20Protocol/Cheat%20Sheet) 5 | 6 | ### [Q&A](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Delegate%20Protocol/Interview%20Questions) 7 | -------------------------------------------------------------------------------- /Classes & structures /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Classes & structures 3 | 4 | ## [Cheat Sheet](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Classes%20%26%20structures%20/Cheat%20Sheet) 5 | 6 | ## [Q&A](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Classes%20%26%20structures%20/Cheat%20Sheet) 7 | -------------------------------------------------------------------------------- /Concurrency and Threading/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Concurrency and Threading 3 | 4 | ### [Concurrency and Threads](https://github.com/JoJoDevAdventure/Swift-Interview/blob/main/Concurrency%20and%20Threading/Cheat%20Sheet/What%20is%20concurrency.md) 5 | 6 | ### [Queues](https://github.com/JoJoDevAdventure/Swift-Interview/blob/main/Concurrency%20and%20Threading/Cheat%20Sheet/What%20are%20Queues.md) 7 | 8 | ### [Q&A](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Concurrency%20and%20Threading/Interview%20Questions) 9 | -------------------------------------------------------------------------------- /Unwrapping optional/Cheat Sheet/If let.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | 4 | var optionalNumber: Int? 5 | // optionalNumber can be an Int or a nil 6 | // Unwrap is to check out if optionalNuber is nil or has a value 7 | 8 | //optionalNumber = 27 9 | /// uncomment the above line to test what happens if it has a value (27) 10 | 11 | if let optionalNumber = optionalNumber { 12 | // if optionalNumber == existant value on optionalNumber 13 | print("We have a value and it's \(optionalNumber)") 14 | } else { 15 | // if we have no value 16 | print("We dont have a value, it's nil :( ") 17 | } 18 | -------------------------------------------------------------------------------- /Unwrapping optional/Cheat Sheet/guard let.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | var optionalNumber: Int? 4 | // optionalNumber can be an Int or a nil 5 | // Unwrap is to check out if optionalNuber is nil or has a value 6 | 7 | //optionalNumber = 27 8 | /// uncomment the above line to test what happens if it has a value (27) 9 | 10 | func returnStringIfNumberExist() -> String { 11 | //checking if we have a value 12 | guard optionalNumber == optionalNumber else { 13 | //we dont have a value so the function will exit 14 | return "We done have a value, it's nil" 15 | } 16 | // we have a value the function will continue execution 17 | return "we have value, it's \(optionalNumber)" 18 | } 19 | print(returnStringIfNumberExist()) 20 | -------------------------------------------------------------------------------- /Concurrency and Threading/Cheat Sheet/What is concurrency.md: -------------------------------------------------------------------------------- 1 | # Concurrency & Threads : 2 | 3 | ## What is concurrency? 4 | 5 | Concurrency is doing multiple tasks in the same time. 6 | 7 | The more cores you have, the more tasks you can execute at the same time. 8 | 9 | Threads are like the path that tasks take. 10 | 11 | ## There are two types of threads: 12 | 13 | ### Main Background 14 | 15 | #### Main thread: 16 | Fast, For UI, light tasks.. 17 | #### Back thread: 18 | Slower, For heavy tasks... 19 | 20 | ![Aspose Words f029770a-b13b-481b-b2fb-fde073a8d16f 001](https://user-images.githubusercontent.com/89042174/170587998-ec008171-363e-4f79-9876-f4784eb6d15a.jpeg) 21 | 22 | (on the left is a representation of Main thread, and right the Back Thread) 23 | -------------------------------------------------------------------------------- /Unwrapping optional/Cheat Sheet/optional chaining.swift: -------------------------------------------------------------------------------- 1 | 2 | import UIKit 3 | 4 | // Optional Chaining 5 | // essentially used with struct 6 | // here's an example 7 | struct Car { 8 | var type: String 9 | var price: Float 10 | var power: Int 11 | } 12 | 13 | // ferrari is an optional object of type Car struct 14 | var ferrari: Car? 15 | 16 | 17 | //ferrari = Car(type: "ferrari", price: 1000, power: 10) 18 | /// uncomment the above line to get non nil value 19 | 20 | let ferrariPrice = ferrari?.price 21 | // ferrari price is going to be an optional value automaticly 22 | 23 | /// now we want to add 99.99 to ferrariPrice 24 | 25 | // we're adding '99.99' to an optional variable => Error 26 | //let TTCPrice = ferrariPrice + 99.99 27 | 28 | // here's the right way to do it 29 | 30 | //we check if it's nil 31 | if let ferrariPrice = ferrariPrice { 32 | // not nil 33 | print("TTC Price = \(ferrariPrice + 99.99)") 34 | } else { 35 | print("nill") 36 | } 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2022 JoJoDevAdventure 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Classes & structures /Cheat Sheet/Classes and Struct.swift: -------------------------------------------------------------------------------- 1 | 2 | /// Classes are reference type 3 | 4 | class iphone { 5 | 6 | var year : Int 7 | var color : String 8 | var price : Double 9 | 10 | init(year: Int, color: String, price: Double) { 11 | self.year = year 12 | self.color = color 13 | self.price = price 14 | } 15 | } 16 | 17 | let myiPhone = iphone(year: 2022, color: "red", price: 1000) 18 | 19 | // creating another phone wich is equal to myiPhone 20 | let stoleniPhone = myiPhone 21 | 22 | // changing the new phone (stolen) price 23 | stoleniPhone.price = 600 24 | 25 | print(myiPhone.price) 26 | // we can observe that it changes the original phone (myiPhone) price too. 27 | 28 | /// structs are value type 29 | 30 | struct iPad { 31 | var number: Int 32 | var color: String 33 | 34 | //no neeed to init 35 | } 36 | 37 | let myiPad = iPad(number: 4, color: "white") 38 | 39 | //creating an instance of myiPad (copy) 40 | var stoleniPad = myiPad 41 | 42 | // changing the stolen iPad color 43 | stoleniPhone.color = "white" 44 | 45 | //it doesn't change my iPad color 46 | print(myiPad.color) 47 | -------------------------------------------------------------------------------- /Unwrapping optional/Cheat Sheet/force unwrap.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | var optionalNumber: Int? 4 | // optionalNumber can be an Int or a nil 5 | // Unwrap is to check out if optionalNuber is nil or has a value 6 | 7 | //optionalNumber = 27 8 | /// uncomment the above line to test what happens if it has a value (27) 9 | 10 | //Force unwraping is 11 | let forced = optionalNumber! 12 | 13 | /* if we have a value, 'forced' will get the value of 'optionalNumber 14 | if we don't, the app will crash with "fatal error: unexpectedly found nil while unreapping an Optional Value, 15 | we must be carefull with the usage of this unwrapping 16 | */ 17 | 18 | /// example secure force unwrap use 19 | 20 | func checkError (error: String?) -> String { 21 | // here we can check if there is an error 22 | guard error == nil else { 23 | // error != nil so we're sure that we have an error 24 | return error! 25 | } 26 | // error is nil 27 | return "no error" 28 | } 29 | 30 | // no error 31 | print(checkError(error: nil)) 32 | // with error 33 | print(checkError(error: "error while sign in")) 34 | 35 | /// in 99% of case we dont use force unwrap beacause it's not a good practice 36 | -------------------------------------------------------------------------------- /Concurrency and Threading/Cheat Sheet/What are Queues.md: -------------------------------------------------------------------------------- 1 | # Queues : 2 | 3 | ## What are Queues? 4 | 5 |
6 | like a queue of peoples waiting to enter a cinema or theatre,
7 | Queues are also tasks waiting to be executed in the program,
8 | The most used Queue is FIFO, First In First Out, 9 | first task that asks to get executed have priority. 10 |
11 |
12 | 13 | ![Screenshot 2022-05-26 at 23 36 01](https://user-images.githubusercontent.com/89042174/170590724-0f40c654-6795-40a3-ab97-b7785e8a66df.png) 14 | ## There are two types of Queues: 15 | 16 | ### Serial Queues : 17 | 18 | #### Task 2 waits for task 1 to finish 19 | 20 |
21 | 22 | ![Screenshot 2022-05-26 at 23 41 25](https://user-images.githubusercontent.com/89042174/170591763-51819ba7-84ae-430c-887a-c36fd484deb0.png) 23 | 24 |
25 | 26 | #### Pros : 27 | We can predict the order of execution. 28 | #### Cons : 29 | Slow execution since every task needs to wait the turn to begin execution. 30 | ### Concurent Queues : 31 | #### All tasks execute together. 32 |
33 | 34 | ![Screenshot 2022-05-26 at 23 46 22](https://user-images.githubusercontent.com/89042174/170591753-9c07aad1-77ed-4688-8bc1-93e7437533f4.png) 35 | 36 |
37 | 38 | #### Pros : 39 | We can predict the order of execution. 40 | #### Cons : 41 | Slow execution since every task needs to wait the turn to begin execution. 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift Interview 2 | Hello everyone, with this repo I'm preparing for my Swift technical questions, so you'll find examples and frequently asked questions about: 3 | 4 | * ### [Unwrapping optional](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Unwrapping%20optional) 5 | * ### [Classes & structures](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Classes%20%26%20structures%20) 6 | * ### [Bounds vs. Frame](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Bounds%20vs.%20Frame) 7 | * ### [Error handling, do, try, catch](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Error%20handling%2C%20do%2C%20try%2C%20catch) 8 | * ### [Concurrency and Threading](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Concurrency%20and%20Threading) 9 | * ### [Filter, Map, Reduce](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Filter%2C%20Map%2C%20Reduce) 10 | * ### [Observer & Notification Pattern](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Observer%20%26%20Notification%20Pattern) 11 | * ### [Delegate Protocol](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Delegate%20Protocol) 12 | * ### [Gesture Recognizer](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Gesture%20Recognizer) 13 | * ### [Retain Cycle, Automatic Reference Counting, Memory Leak](https://github.com/JoJoDevAdventure/Swift-Interview/tree/main/Retain%20Cycle%2C%20Automatic%20Reference%20Counting%2C%20Memory%20Leak) 14 | 15 | More topics will be added as I learn them. 16 | 17 | This repo is public so if it's helpful don't foget to star and follow me. 18 | --------------------------------------------------------------------------------