├── .DS_Store ├── README.md ├── SwiftInterviewQuestions ├── .DS_Store ├── CoreData │ └── SwiftInterviewQuestions.xcdatamodeld │ │ └── SwiftInterviewQuestions.xcdatamodel │ │ └── contents ├── Ignore │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── SceneDelegate.swift │ └── ViewController.swift ├── Info.plist ├── SwiftInterviewQuestions.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── zachary.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── zachary.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── SwiftInterviewQuestions │ ├── CoreData │ │ └── SwiftInterviewQuestions.xcdatamodeld │ │ │ └── SwiftInterviewQuestions.xcdatamodel │ │ │ └── contents │ ├── Ignore │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AccentColor.colorset │ │ │ │ └── Contents.json │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── SceneDelegate.swift │ │ └── ViewController.swift │ ├── Info.plist │ └── SwiftPlaygroundExamples │ │ ├── ArrayEnumDictSet.playground │ │ ├── Contents.swift │ │ ├── contents.xcplayground │ │ └── playground.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ ├── Constants.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── Fizz_Buzz_FizzBuzz.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── GettersAndSetters.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── InOut.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── Loops.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── Old │ │ └── interviewproblems.playground │ │ │ └── playground.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcuserdata │ │ │ └── zachary.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ ├── Optionals.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── StructAndClass.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── Tuples.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ ├── Variable.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground │ │ └── raywenderlichProblems.playground │ │ ├── Contents.swift │ │ └── contents.xcplayground ├── SwiftInterviewQuestionsTests │ └── SwiftInterviewQuestionsTests.swift ├── SwiftInterviewQuestionsUITests │ ├── SwiftInterviewQuestionsUITests.swift │ └── SwiftInterviewQuestionsUITestsLaunchTests.swift └── SwiftPlaygroundExamples │ ├── ArrayEnumDictSet.playground │ ├── Contents.swift │ └── contents.xcplayground │ ├── InOut.playground │ ├── Contents.swift │ └── contents.xcplayground │ ├── Loops.playground │ ├── Contents.swift │ └── contents.xcplayground │ ├── Old │ └── interviewproblems.playground │ │ └── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ └── zachary.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── Optionals.playground │ ├── Contents.swift │ └── contents.xcplayground │ ├── StructAndClass.playground │ ├── Contents.swift │ └── contents.xcplayground │ └── Variable.playground │ ├── Contents.swift │ └── contents.xcplayground └── interviewproblems.playground.zip /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmithZachary/SwiftInterviewProblems/c0639409bd39a3c4401f8db6e9e748b961ed4a6e/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftInterviewProblems 2 | ## Two Parts -- Swift Playgrounds & Read Me 3 | # Swift Interview Problems in Playground 4 | you may have to copy and paste the code into a new playground git oesnt play nice with playground files 5 | ## ***Update, added a actual xcode project, with multiple swift playgrounds broken down by category, makes it easier to clone and read!*** 6 | A compilation of general interview questions for a jr. dev in swift. 7 | It's made in swift playground so you can hopefully see some of the code working 8 | a little better than on a website in text. It is a work in product, feel free 9 | to add to it and make this a go to review source for everyone! 10 | 11 | questions, comments, want to talk? 12 | ### instagram and twitter @spacemulecode 13 | 14 | ## READ ME INFO EXTRACTED FROM ONTHECODEPATH 15 | 16 | # Hello fellow iOS Developers! 17 | 18 | ## What is this for? 19 | 20 | Time is important. It's frustrating and time-consuming to have to search endlessly in order to practice iOS interview questions. The goal of this open-source project is to collect as many iOS interview questions together along with answers in order to save you time. 21 | 22 | ## Practice 23 | 24 | Use the Table of Contents to practice and test your knowledge. It doesn't show the answer so you'll be able to go over the questions without relying on the answer for help. 25 | 26 | ## Table of Contents 27 | 28 | - [Database](https://github.com/onthecodepath/iOS-Interview-Questions#database) 29 | - What is Core Data? 30 | - When would you use Core Data over NSUserDefault? 31 | - What is a managed object context? 32 | - What is NSFetchRequest? 33 | - [Debugging](https://github.com/onthecodepath/iOS-Interview-Questions#debugging) 34 | - What are some ways of debugging in iOS? 35 | - [Design Pattern](https://github.com/onthecodepath/iOS-Interview-Questions#design-patterns) 36 | - What is Singleton Pattern? 37 | - What is the delegation pattern? 38 | - What is MVC? 39 | - What is MVVM? 40 | - [General / Uncategorized](https://github.com/onthecodepath/iOS-Interview-Questions#general--uncategorized) 41 | - What considerations do you need when writing a UITableViewController which shows images downloaded from a remote server? 42 | - What is a protocol? How do you define your own protocol? 43 | - What is waterfall methodology and Agile methodology? What are the differences between them? 44 | - What is the difference between a class and an object? 45 | - What is JSON? What are the pros and cons? 46 | - What is the difference between not-running, inactive, active, background and suspended execution states? 47 | - Is it faster to iterate through an NSArray or an NSSet? 48 | - What is KVO? 49 | - [Memory Management](https://github.com/onthecodepath/iOS-Interview-Questions#memory-management) 50 | - Why do you generally create a weak reference when using self in a block? 51 | - What is memory management handled on iOS? 52 | - What is the difference between *weak* and *strong*? 53 | - What is a memory leak? 54 | - What is a retain cycle? 55 | - What is the difference between copy and retain? 56 | - What is the difference between a stack vs a heap? 57 | - [Networking](https://github.com/onthecodepath/iOS-Interview-Questions#networking) 58 | - [Objective-C](https://github.com/onthecodepath/iOS-Interview-Questions#objective-c) 59 | - What is synthesize in Objective-C? 60 | - What is dynamic in Objective-C? 61 | - What is the difference between _name vs self.name? 62 | - What are blocks in Objective-C? 63 | - What is the difference between category and extension in Objective-C? 64 | - [Swift](https://github.com/onthecodepath/iOS-Interview-Questions#swift) 65 | - What is the difference between public and open? Why is it important to have both? 66 | - What is the difference between var and let? 67 | - What is the difference between a struct and a class? 68 | - What is the difference between implicit and explicit? 69 | - [Thread Management](https://github.com/onthecodepath/iOS-Interview-Questions#thread-management) 70 | - What is the difference between synchronous and asynchronous task? 71 | - What is the difference between atomic and non-atomic synthesized properties? 72 | - What is GCD and how is it used? 73 | - Explain the difference between Serial vs Concurrent. 74 | - [Unit Testing / UI Testing](https://github.com/onthecodepath/iOS-Interview-Questions#unit-testing--ui-testing) 75 | - What is the purpose of unit testing? What are the benefits? 76 | - [View / Storyboard](https://github.com/onthecodepath/iOS-Interview-Questions#view--storyboard) 77 | - What is the difference between viewDidLoad and viewDidAppear? Which should you use to load data from a remote server to display in the view? 78 | - What is the difference between frame and bound of a UIView? 79 | - What is the reuseIdentifier for? 80 | - What is autolayout? 81 | - [Algorithm Resources](https://github.com/onthecodepath/iOS-Interview-Questions#algorithm-resources) 82 | - EKAlgorithm 83 | - swift-algorithm-club 84 | - [Contributing](https://github.com/onthecodepath/iOS-Interview-Questions#contributing) 85 | - [Thank You](https://github.com/onthecodepath/iOS-Interview-Questions#thank-you) 86 | - [Flashcards](https://quizlet.com/serg_tsogtbaatar/folders/ios-interviews/sets) 87 | - The interview questions as flash card sets according to topic. 88 | 89 | # Interview Questions & Answers 90 | 91 | 92 | ## Database 93 | 94 | #### What is Core Data? 95 | 96 | Core Data is a framework that is used to manage model layer objects. It has the ability to persist object graphs to a persistent store. Data is organized into relational entity-attribute model. 97 | 98 | #### When would you use Core Data over NSUserDefault? 99 | 100 | NSUserDefault is typically used to store small bits of data (settings, preferences, etc.). Core Data is used to store a large list of elements. 101 | 102 | #### What is a managed object context? 103 | 104 | First, managed object context is an instance of NSManagedObjectContext. It is the central object in the Core Data stack. It is used to create and fetch managed objects, and to manage undo and redo operations. Although it is allowed to have multiple managed object contexts, there is typically at most one managed object to represent any given record in a persistent store. 105 | 106 | #### What is NSFetchRequest? 107 | 108 | NSFetchRequest is the class responsible for fetching from Core Data. Fetch requests can be used to fetch a set of objects meeting a certain criteria, individual values and more. ([source](https://medium.com/ios-os-x-development/50-ios-interview-questions-and-answers-part-2-45f952230b9f)) 109 | 110 | ## Debugging 111 | 112 | #### What are some ways of debugging in iOS? 113 | 114 | - NSLog and print functions can be used for output into console. 115 | - Breakpoints can also be used together with the Debug bar and Variables view as an alternative. 116 | - Senior devs often use other tools such as Instruments and Crash Logs instead of the two above. 117 | 118 | ## Design Patterns 119 | 120 | #### What is Singleton Pattern? 121 | 122 | The Singleton design pattern ensures that only one instance exists for a given class and that there’s a global access point to that instance. It usually uses lazy loading to create the single instance when it’s needed the first time. ([source](https://medium.com/ios-os-x-development/ios-interview-questions-13840247a57a)) 123 | 124 | #### What is the delegation pattern? 125 | 126 | The delegation pattern is a powerful pattern used in building iOS applications. The basic idea is that one object will act on another object's behalf or in coordination with another object. The delegating object typically keeps a reference to the other object (delegate) and sends a message to it at the appropriate time. It is important to note that they have a one to one relationship. 127 | 128 | #### What is MVC? 129 | 130 | MVC stands for **Model-View-Controller**. It is a software architecture pattern for implementing user interfaces. 131 | 132 | MVC consists of three layers: the model, the view, and the controller. 133 | - The **model layer** is typically where the data resides (persistence, model objects, etc) 134 | - The **view layer** is typically where all the UI interface lies. Things like displaying buttons and numbers belong in the view layer. The view layer does not know anything about the model layer and vice versa. 135 | - The **controller (view controller)** is the layer that integrates the view layer and the model layer together. 136 | 137 | #### What is MVVM? 138 | 139 | MVVM stands for **Model-View-ViewModel**. It is a software architecture pattern for implementing user interfaces. 140 | 141 | MVVM is an augmented version of MVC where the presentation logic is moved out of the controller and into the view model. The view model is responsible for handling most, if not all, of the view's display logic. 142 | 143 | A common occurence in MVC is where you have a massive-view-controller (some joke this is what MVC stands for). In order to shrink the size of your view controller and make the logic and readibility of your code easier to follow along, the MVVM will be used. 144 | 145 | ## General / Uncategorized 146 | 147 | #### What considerations do you need when writing a UITableViewController which shows images downloaded from a remote server? 148 | 149 | - Only download the image when the cell is scrolled into view (when cellForRowAtIndexPath is called) 150 | - Download the image asynchronously on a background thread so as not to block the UI so the user can keep scrolling 151 | - When the image has downloaded for a cell, check if that cell is still in the view or whether it has been re-used by another piece of data. If the cell has been re-used, then the image should be discarded. Otherwise, it should be switched back to the main thread to change the image on the cell. ([source](https://www.codementor.io/mattgoldspink/ios-interview-tips-questions-answers-objective-c-du1088nfb)) 152 | 153 | #### What is a protocol? How do you define your own protocol? 154 | 155 | A protocol defines a list of required and optional methods for a class that adopts the protocol to implement. Any class is allowed to implement a protocol so that other classes can send message to it based on the protocol methods without knowing the type of class. An example of how a protocol is defined: 156 | 157 |
158 | Objective-C 159 | 160 | ```objective-c 161 | @protocol MyCustomDataSource 162 | - (NSUInteger)numberOfRecords; 163 | - (NSDictionary *)recordAtIndex:(NSUInteger)index; 164 | @optional 165 | - (NSString *)titleForRecordAtIndex:(NSUInteger)index; 166 | @end 167 | ``` 168 |
169 | 170 | A common instance protocols are used is providing a DataSource for UITableView or UICollectionView ([source](https://www.codementor.io/mattgoldspink/ios-interview-tips-questions-answers-objective-c-du1088nfb)) 171 | 172 | #### What is waterfall methodology and Agile methodology? What are the differences between them? 173 | 174 | Waterfall methodology is a sequential model for software development. It is separated into a sequence of pre-defined phases including feasibility, planning, design, build, test, production, and support. 175 | 176 | On the other hand, Agile development methodology is a linear sequential apporach that provides flexibility for changing project requirements. 177 | 178 | List of differences: 179 | - Waterfall model divides software development process into different phases while Agile segregates the project development lifecycle into sprints. This makes waterfall more rigid while agile allows for more flexibility 180 | - Waterfall model describes the software development life cycle as a single project while Agile considers it as a collection of many different projects; are iterations of different phases focusing on improving overall software quality with feedback from users and QA team. 181 | - Since waterfall is more rigid, development requirements need to be clearly established beforehand since there is little flexibility for changing once project development starts. Meanwhile, Agile allow changes to be made anytime along the project development process even after initial planning has been completed. 182 | - In Waterfall, the testing phase typically occurs after the build phase. In Agile, testing is often performed concurrently with programming or at least in the same iteration. 183 | - Waterfall is more of an interal process that does not involve user feedback. Agile tends to involve user participation more in order to improve customer satisfaction. 184 | - Waterfall model best fits projects that have a clearly defined set of requirements and where change to requirements is not expect. Agile fits more for projects where the requirements are expected to change and evolve. 185 | - Waterfall can exhibit a project mindset that focuses on completion of the project while Agile can allow for more focus on developing a product that satisfies customers. 186 | 187 | #### What is the difference between a class and an object? 188 | 189 | In the simplest sense, a class is a blueprint for an object. It describes the properties and behaviors common to any particular type of object. An object, on the other hand, is an instance of a class. 190 | 191 | #### What is JSON? What are the pros and cons? 192 | 193 | JSON stands for JavaScript Object Notation. According to [wiki](https://en.wikipedia.org/wiki/JSON), it is a file format that uses human-readable text to transmite data objects consisting of attribute-value pairs and array data types. 194 | 195 | Pros: 196 | 197 | - It is lighter than XML meaning that it can represent the same data in XML in fewer bytes. This makes network transmissions and read/writes faster 198 | - Since it is native to JavaScript, computationally-expensive XSL tranformations are not needed in order to extract data 199 | 200 | Cons: 201 | 202 | - Not as widespread as XML 203 | - Data is not readily streamable and has to be broken up into individual objects 204 | - Can't use comments 205 | 206 | #### What is the difference between not-running, inactive, active, background and suspended execution states? 207 | 208 | - **Not-running state** occurs when the app either has not be launched or was running but was terminated by the system. 209 | - **Inactive state** occurs where the app runs in the foreground but is currently not receiving events. (It may be executing other code though). This state is typically brief as apps transitions to other states. 210 | - **Active state** is where the app is running in the foreground and receiving events. This is the normal mode for foreground apps. 211 | - **Background state** occurs when the app is in the background and executing code. Apps typically enter this state on their way to being suspended. Apps that require extra execution time may remain in this screen longer. Apps being launched directly into the background enters this state instead of inactive state. 212 | - **Suspended state** is where the app is in the background but it is not executing code. Apps will remain in memory, but are removed by the system if low-memory condition occurs in order to make more space for foreground apps. 213 | 214 | #### Is it faster to search for an item in an NSArray or an NSSet? 215 | 216 | It depends. NSSet is faster to lookup an item in but can hold at most one of any given object. The reason is because NSSet uses hash values in order to find items. NSArray can hold multiple copies of an object but is slower to search for an item as it has to iterate through its entire contents to find it. ([source - #25](https://medium.com/cocoaacademymag/25-ios-interview-questions-and-answers-for-junior-developers-19bfe6e99b0)) 217 | 218 | #### What is KVO? 219 | 220 | KVO stands for *Key-Value Observing*. It allows a controller or class to *observe* when a property value changes. 221 | 222 | ## Memory Management 223 | 224 | #### Why do you generally create a weak reference when using self in a block? 225 | 226 | Sometimes it is necessary it capture self in a block such as when defining a callback block. However, since blocks maintain strong references to any captured objects including self, this may lead to a strong reference cycle and memory leak. 227 | 228 | Instead, capturing a weak reference to self is recommended in order to avoid this issue: 229 | 230 |
231 | Objective-C 232 | 233 | ```objective-c 234 | SomeBlock* __weak weakSelf = self; 235 | ``` 236 |
237 | 238 | 239 | #### What is memory management handled on iOS? 240 | 241 | iOS uses something called ARC which stands for Automatic Reference Counting. When an object is said to have a strong reference to it, ARC increase its retain count by 1. When the retain count of an object reaches 0, the object will typically be deallocated if there are no more strong references to it. Unlike garbage collection, ARC does not handle reference cycles automatically. 242 | 243 | #### What is the difference between *weak* and *strong*? 244 | 245 | First, objects are *strong* by default. 246 | 247 | - *Strong* means that the reference count will be increased and the reference to it will be maintained through the life of the object. 248 | - *Weak*, means that we are pointing to an object but not increasing its reference count. It’s often used when creating a parent child relationship. The parent has a strong reference to the child but the child only has a weak reference to the parent. ([source](https://medium.com/ios-os-x-development/ios-interview-questions-13840247a57a)) 249 | 250 | Common instances of *weak* references are delegate properties and subview/controls of a view controller's main view since those views are already strongly held by the main view. ([source](http://stackoverflow.com/questions/11013587/differences-between-strong-and-weak-in-objective-c)) 251 | 252 | #### What is a memory leak? 253 | 254 | A memory leak commonly occurs when an object is allocated in such a way that when it is no longer in use or needed, it is not released. In iOS programming, you create certain objects with weak references in order to avoid a strong to strong relationship that creates a retain cycle and a memory leak. 255 | 256 | #### What is a retain cycle? 257 | 258 | Retain cycles can occur when memory management is based on retain count. This typically occurs when two objects strongly reference each other. As a result, the retain count of either object will never reach zero and deallocated from memory (hence retaining each other). 259 | 260 | #### What is the difference between *copy* and *retain*? 261 | 262 | Calling *retain* on an object will increase its *retain* count by one. When the *retain* count of an objective reaches 0, the object will be deallocated and released from memory. 263 | 264 | When you *retain* an object, you share the same version with whoever passed the object to you. But when you *copy* an object, you do not share the same version of the object that was passed to you. Instead, a duplicate of that object is created with duplicated values. 265 | 266 | #### What is the difference between a stack vs a heap? 267 | 268 | A stack is a region of memory where data is added or removed in a last-in-first-out (LIFO) order. According to [Ates Goral](http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap), it is the memory set aside as scratch space for a thread of execution. Meanwhile the heap is memory set aside for dynamic allocation. Unlike the stack, you can allocate a block at any time and free it at anytime. 269 | 270 | Note: In Objective-C, all objects are always allocated on the heap, or at least should be treated as if on the heap. 271 | 272 | ## Networking 273 | 274 | ## Objective-C 275 | 276 | #### What is synthesize in Objective-C? 277 | 278 | *Synthesize* generates getter and setter methods for your property. 279 | 280 | #### What is dynamic in Objective-C? 281 | 282 | Dynamic is used for subclasses of NSManagedObject. @dynamic can also be used to delegate the responsibility of implementing the accessors. ([source](https://medium.com/ios-os-x-development/ios-interview-questions-13840247a57a)) 283 | 284 | #### What is the difference between _ vs self. in Objective-C? 285 | 286 | You typically use either when accessing a property in Objective-C. When you use _, you're referencing the actual instance variable directly. You should avoid this. Instead, you should use self. to ensure that any getter/setter actions are honored. 287 | 288 | In the case that you would write your own setter method, using _ would not call that setter method. Using self. on the property, however, would call the setter method you implemented. 289 | 290 | #### What are blocks in Objective-C? 291 | 292 | Blocks are a language-level feature of Objective (C and C++ too). They are objects that allow you to create distinct segments of code that can be passed around to methods or functions as if they were values. This means that a block is capable of being added to collections such as NSArray or NSDictionary. Blocks are also able to take arguments and return values similar to methods and functions. 293 | 294 | The syntax to define a block literal uses the caret symbol(^): 295 | 296 |
297 | Objective-C 298 | 299 | ```objective-c 300 | ^{ 301 | NSLog(@"This is an example of a block") 302 | } 303 | ``` 304 |
305 | 306 | #### What is the difference between category and extension in Objective-C? 307 | 308 | A category and extension are similar in functionality where they can add additional instance and class methods to a class. However, an extension can only do so if the source code for the class being extended is available at compile time. This means that classes such as NSString cannot be extended. Instead, a category would be used to add additional methods to the NSString class 309 | 310 | ## Swift 311 | 312 | #### What is the difference between public and open? Why is it important to have both? 313 | 314 | Open access imposes limitations on class inheritance. Classes declared with open level access can be subclassed by modules they are defined in, modules that import the module in which the class is defined, and class members as well. While this sounds similar to the public access level defined in Swift 2, there is a small difference. In Swift 3, the meaning of public access level means that classes declared public can only be subclassed in the module they are defined in. This includes public class members which can be overridden by subclasses defined int he module they are defined in. 315 | 316 | Some classes of libraries and frameworks are not designed to be subclasses. For example, in the Core Data framework, Apple states that some methods of NSManagedObject should not be overridden. To prevent any unexpected behavior that may result from overriding those methods, Apple declares those methods public rather than open. As a result, those methods are not marked as open for developers to override. ([source](https://cocoacasts.com/what-is-the-difference-between-public-and-open-in-swift-3/)) 317 | 318 | #### What is the difference between *var* and *let*? 319 | 320 | *var* is a variable that can be changed while *let* denotes a constant that cannot be changed once set. 321 | 322 | #### What is the difference between a struct and a class? 323 | 324 | The main difference to note is that structs are value types (stored on stack) while classes are reference types (stored on heap). 325 | 326 | Classes have capabilities that structs do not: 327 | - Inheritance enables one class to inherit the characteristics of another. ([source](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/ClassesAndStructures.html)) 328 | - Type casting enables you to check and interpret the type of a class instance at runtime. 329 | - Deinitializers enable an instance of a class to free up any resources it has assigned. 330 | - Reference counting allows more than one reference to a class instance. 331 | 332 | #### What is the difference between implicit and explicit? 333 | 334 | When referring to something as implicit or explicit, it is often referring to how an object is declared. In the two examples below: 335 | 336 |
337 | Swift 338 | 339 | ```swift 340 | var name: String = "onthecodepath" // explicit 341 | var name = "onthecodepath" // implicit 342 | ``` 343 |
344 | 345 | In the first line above, the name variable is *explicitly* declared since the type of the variable follows the name of the variable. In the second line, the String type is not explicitly declared. However, Swift is able to infer that name is of a String type since the value that it is being set as is of a String type. 346 | 347 | ## Thread Management 348 | 349 | #### What is the difference between synchronous and asynchronous task? 350 | 351 | Synchronous tasks wait until the task has been completed while asynchronous tasks can run in the background and send a notification when the task is complete. 352 | 353 | #### What is the difference between *atomic* and *non-atomic* synthesized properties? 354 | 355 | First, properties are set to *atomic* by default. 356 | 357 | *Atomic* properties are more likely to guarentee thread-safety because it will ensure that a value is fully set (by the setter method) or fully retrieved (by the getter method) when accessor methods are called simultaneously. 358 | 359 | *Non-atomic* properties, however are not thread-safe. While they run faster, they may cause race conditions. In the event that accessor methods are called simultaneously and a race condition occurs, a setter value would first release the old value and a getter method would retrieve nil since no value has not been set yet. 360 | 361 | #### What is GCD and how is it used? 362 | 363 | GCD stands for Grand Central Dispatch. According to [Ray Wenderlich](https://www.raywenderlich.com/60749/grand-central-dispatch-in-depth-part-1), it offers the following benefits 364 | - Improving your app's responsiveness by helping to defer computationally expensive tasks and run them in the background. 365 | - Providing an easier concurrency model than locks and threads and helps to avoid concurrency bugs. 366 | - Potentially optimize your code with higher performance primitives for common patterns such as singletons. 367 | 368 | In other words, GCD provides and manages queues of tasks in the iOS app. This is one of the most commonly used API to manage concurrent code and execute operations asynchronously. Network calls are often performed on a background thread while things like UI updates are executed on the main thread. 369 | 370 | #### Explain the difference between Serial vs Concurrent 371 | 372 | Tasks executed *serially* are executed one at a time while tasks that are executed *concurrently* may be executed at the same time. 373 | 374 | #### Spot the bug that occurs in the code: 375 | 376 |
377 | Swift 378 | 379 | ```swift 380 | class ViewController: UIViewController { 381 | @IBOutlet var alert: UILabel! 382 | override func viewDidLoad() { 383 | super.viewDidLoad() 384 | let frame: CGRect = CGRect(x: 100, y: 100, width: 100, height: 50) 385 | self.alert = UILabel(frame: frame) 386 | self.alert.text = "Please wait..." 387 | self.view.addSubview(self.alert) 388 | } 389 | DispatchQueue.global(qos: .default).async { 390 | sleep(10) 391 | self.alert.text = "Waiting over" 392 | } 393 | } 394 | ``` 395 |
396 | 397 |
398 | Objective-C 399 | 400 | ```objective-c 401 | @interface MyCustomController : UIViewController 402 | @property (strong, nonatomic) UILabel *alert; 403 | @end 404 | 405 | @implementation MyCustomController 406 | 407 | - (void)viewDidLoad { 408 | CGRect frame = CGRectMake(100, 100, 100, 50); 409 | self.alert = [[UILabel alloc] initWithFrame:frame]; 410 | self.alert.text = @"Please wait..."; 411 | [self.view addSubview:self.alert]; 412 | dispatch_async( 413 | dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), 414 | ^{ 415 | sleep(10); 416 | self.alert.text = @"Waiting over"; 417 | } 418 | ); 419 | } 420 | ``` 421 |
422 |
423 | 424 | All UI updates must be performed on the main thread. Global dispatch queues do not make any guarantees so code should be modified to run the UI update on the main thread. Here is the fix below: 425 | 426 | 427 |
428 | Swift 429 | 430 | ```swift 431 | DispatchQueue.global(qos: .default).async { 432 | sleep(10) 433 | DispatchQueue.main.async { 434 | self.alert.text = "Waiting over" 435 | } 436 | } 437 | ``` 438 |
439 | 440 |
441 | Objective-C 442 | 443 | ``` 444 | dispatch_async( 445 | dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), 446 | ^{ 447 | sleep(10); 448 | dispatch_async(dispatch_get_main_queue(), ^{ 449 | self.alert.text = @"Waiting over"; 450 | }); 451 | }); 452 | 453 | ``` 454 |
455 | 456 | ## Unit Testing / UI Testing 457 | 458 | #### What is the purpose of unit/UI testing? What are the benefits? 459 | 460 | Unit/UI testing are the basic of test-driven development. This development approach allows you to codify requirements for your code before you implement it. Unit tests are important to make sure that code meets its design and requirements and behaves as expected. Parts of the program are segregated and tested to ensure that individual parts are working correctly. 461 | 462 | ## View / Storyboard 463 | 464 | #### What is the difference between viewDidLoad and viewDidAppear? Which should you use to load data from a remote server to display in the view? 465 | 466 | viewDidLoad is only called when the view is loaded (after loadView is called). viewDidAppear, on the other hand, is called everytime the view appears on the device. 467 | 468 | If the data is static for the most part, it can be loaded in viewDidLoad and cached. But if the data is dynamic and likely to change often, it is preferrable to use viewDidAppear. In both instances, data should be loaded asynchronously on a background thread to avoid blocking the UI. 469 | 470 | #### What is the difference between frame and bound of a UIView? 471 | 472 | The *frame* of a UIView is the region relative to the superview it is contained within while the *bounds* of a UIView is the region relative to its own coordinate system. 473 | 474 | #### What is the reuseIdentifier for? 475 | 476 | The *reuseIdentifier* indicates that cells for a UITableView (or UICollectionView) can be reused. UITableView maintains an internal cache of UITableViewCell with the appropriate identifier and allows them to be reused when dequeueForCellWithReuseIdentifier is called. As a result, this increases performance of UITableView since a new view does not have to be created for a cell. 477 | 478 | #### What is Auto Layout? 479 | 480 | Auto Layout is used to dynamically calculate the size and position of views based on constraints. 481 | 482 | # Algorithm Resources 483 | 484 | #### [EKAlgorithm](https://github.com/EvgenyKarkan/EKAlgorithms): Algorithm and data structures in Objc 485 | 486 | #### [swift-algorithm-club](https://github.com/raywenderlich/swift-algorithm-club): Algorithm and data structures in Swift 487 | 488 | # Contributing 489 | 490 | #### There's a typo / an incorrect answer to one of your questions 491 | 492 | Great! Creating an issue will let me know what changes should be made. You can even making the changes yourself and make a pull request which will expedite the process! 493 | 494 | #### Requesting questions to be answered and topics 495 | 496 | If you open an issue, I would be happy to go ahead and add the question with the appropriate answer when I get to it! 497 | 498 | # Thank You 499 | 500 | #### Contributors 501 | 502 | - onthecodePath 503 | - Sergtsaeb 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmithZachary/SwiftInterviewProblems/c0639409bd39a3c4401f8db6e9e748b961ed4a6e/SwiftInterviewQuestions/.DS_Store -------------------------------------------------------------------------------- /SwiftInterviewQuestions/CoreData/SwiftInterviewQuestions.xcdatamodeld/SwiftInterviewQuestions.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftInterviewQuestions 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import UIKit 9 | import CoreData 10 | 11 | @main 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | // MARK: - Core Data stack 36 | 37 | lazy var persistentContainer: NSPersistentContainer = { 38 | /* 39 | The persistent container for the application. This implementation 40 | creates and returns a container, having loaded the store for the 41 | application to it. This property is optional since there are legitimate 42 | error conditions that could cause the creation of the store to fail. 43 | */ 44 | let container = NSPersistentContainer(name: "SwiftInterviewQuestions") 45 | container.loadPersistentStores(completionHandler: { (storeDescription, error) in 46 | if let error = error as NSError? { 47 | // Replace this implementation with code to handle the error appropriately. 48 | // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 49 | 50 | /* 51 | Typical reasons for an error here include: 52 | * The parent directory does not exist, cannot be created, or disallows writing. 53 | * The persistent store is not accessible, due to permissions or data protection when the device is locked. 54 | * The device is out of space. 55 | * The store could not be migrated to the current model version. 56 | Check the error message to determine what the actual problem was. 57 | */ 58 | fatalError("Unresolved error \(error), \(error.userInfo)") 59 | } 60 | }) 61 | return container 62 | }() 63 | 64 | // MARK: - Core Data Saving support 65 | 66 | func saveContext () { 67 | let context = persistentContainer.viewContext 68 | if context.hasChanges { 69 | do { 70 | try context.save() 71 | } catch { 72 | // Replace this implementation with code to handle the error appropriately. 73 | // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 74 | let nserror = error as NSError 75 | fatalError("Unresolved error \(nserror), \(nserror.userInfo)") 76 | } 77 | } 78 | } 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // SwiftInterviewQuestions 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | 49 | // Save changes in the application's managed object context when the application transitions to the background. 50 | (UIApplication.shared.delegate as? AppDelegate)?.saveContext() 51 | } 52 | 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Ignore/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftInterviewQuestions 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import UIKit 9 | 10 | class ViewController: UIViewController { 11 | 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | // Do any additional setup after loading the view. 15 | } 16 | 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B6DDA7912748BBB0005E239A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6DDA7902748BBB0005E239A /* AppDelegate.swift */; }; 11 | B6DDA7932748BBB0005E239A /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6DDA7922748BBB0005E239A /* SceneDelegate.swift */; }; 12 | B6DDA7952748BBB0005E239A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6DDA7942748BBB0005E239A /* ViewController.swift */; }; 13 | B6DDA7982748BBB0005E239A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B6DDA7962748BBB0005E239A /* Main.storyboard */; }; 14 | B6DDA79B2748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = B6DDA7992748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodeld */; }; 15 | B6DDA79D2748BBB2005E239A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B6DDA79C2748BBB2005E239A /* Assets.xcassets */; }; 16 | B6DDA7A02748BBB2005E239A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B6DDA79E2748BBB2005E239A /* LaunchScreen.storyboard */; }; 17 | B6DDA7AB2748BBB3005E239A /* SwiftInterviewQuestionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6DDA7AA2748BBB3005E239A /* SwiftInterviewQuestionsTests.swift */; }; 18 | B6DDA7B52748BBB3005E239A /* SwiftInterviewQuestionsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6DDA7B42748BBB3005E239A /* SwiftInterviewQuestionsUITests.swift */; }; 19 | B6DDA7B72748BBB3005E239A /* SwiftInterviewQuestionsUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6DDA7B62748BBB3005E239A /* SwiftInterviewQuestionsUITestsLaunchTests.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | B6DDA7A72748BBB3005E239A /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = B6DDA7852748BBB0005E239A /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = B6DDA78C2748BBB0005E239A; 28 | remoteInfo = SwiftInterviewQuestions; 29 | }; 30 | B6DDA7B12748BBB3005E239A /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = B6DDA7852748BBB0005E239A /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = B6DDA78C2748BBB0005E239A; 35 | remoteInfo = SwiftInterviewQuestions; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | B6249744274AEEBC00033BF5 /* Tuples.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Tuples.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 41 | B6249745274AF4B400033BF5 /* Fizz_Buzz_FizzBuzz.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Fizz_Buzz_FizzBuzz.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 42 | B6249746274BEFE400033BF5 /* Constants.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Constants.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 43 | B6249782274DEDE600033BF5 /* GettersAndSetters.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = GettersAndSetters.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 44 | B6C1D675274F2F330033A254 /* raywenderlichProblems.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = raywenderlichProblems.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 45 | B6DDA78D2748BBB0005E239A /* SwiftInterviewQuestions.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftInterviewQuestions.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | B6DDA7902748BBB0005E239A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 47 | B6DDA7922748BBB0005E239A /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 48 | B6DDA7942748BBB0005E239A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 49 | B6DDA7972748BBB0005E239A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | B6DDA79A2748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = SwiftInterviewQuestions.xcdatamodel; sourceTree = ""; }; 51 | B6DDA79C2748BBB2005E239A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 52 | B6DDA79F2748BBB2005E239A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 53 | B6DDA7A12748BBB2005E239A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | B6DDA7A62748BBB3005E239A /* SwiftInterviewQuestionsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftInterviewQuestionsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | B6DDA7AA2748BBB3005E239A /* SwiftInterviewQuestionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftInterviewQuestionsTests.swift; sourceTree = ""; }; 56 | B6DDA7B02748BBB3005E239A /* SwiftInterviewQuestionsUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftInterviewQuestionsUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | B6DDA7B42748BBB3005E239A /* SwiftInterviewQuestionsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftInterviewQuestionsUITests.swift; sourceTree = ""; }; 58 | B6DDA7B62748BBB3005E239A /* SwiftInterviewQuestionsUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftInterviewQuestionsUITestsLaunchTests.swift; sourceTree = ""; }; 59 | B6DDA7C62748BC38005E239A /* Variable.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Variable.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 60 | B6DDA7C72748BC95005E239A /* Loops.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Loops.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 61 | B6DDA7C82748BCEA005E239A /* Optionals.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Optionals.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 62 | B6DDA7C92748BD25005E239A /* StructAndClass.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = StructAndClass.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 63 | B6DDA7CA2748BD72005E239A /* ArrayEnumDictSet.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = ArrayEnumDictSet.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 64 | B6DDA7CB2748BDC4005E239A /* InOut.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = InOut.playground; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 65 | /* End PBXFileReference section */ 66 | 67 | /* Begin PBXFrameworksBuildPhase section */ 68 | B6DDA78A2748BBB0005E239A /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | B6DDA7A32748BBB3005E239A /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | B6DDA7AD2748BBB3005E239A /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXFrameworksBuildPhase section */ 90 | 91 | /* Begin PBXGroup section */ 92 | B6DDA7842748BBB0005E239A = { 93 | isa = PBXGroup; 94 | children = ( 95 | B6DDA78F2748BBB0005E239A /* SwiftInterviewQuestions */, 96 | B6DDA7A92748BBB3005E239A /* SwiftInterviewQuestionsTests */, 97 | B6DDA7B32748BBB3005E239A /* SwiftInterviewQuestionsUITests */, 98 | B6DDA78E2748BBB0005E239A /* Products */, 99 | ); 100 | sourceTree = ""; 101 | }; 102 | B6DDA78E2748BBB0005E239A /* Products */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | B6DDA78D2748BBB0005E239A /* SwiftInterviewQuestions.app */, 106 | B6DDA7A62748BBB3005E239A /* SwiftInterviewQuestionsTests.xctest */, 107 | B6DDA7B02748BBB3005E239A /* SwiftInterviewQuestionsUITests.xctest */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | B6DDA78F2748BBB0005E239A /* SwiftInterviewQuestions */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | B6DDA7A12748BBB2005E239A /* Info.plist */, 116 | B6DDA7C52748BC1A005E239A /* SwiftPlaygroundExamples */, 117 | B6DDA7C42748BC0E005E239A /* CoreData */, 118 | B6DDA7C32748BBEC005E239A /* Ignore */, 119 | ); 120 | path = SwiftInterviewQuestions; 121 | sourceTree = ""; 122 | }; 123 | B6DDA7A92748BBB3005E239A /* SwiftInterviewQuestionsTests */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | B6DDA7AA2748BBB3005E239A /* SwiftInterviewQuestionsTests.swift */, 127 | ); 128 | path = SwiftInterviewQuestionsTests; 129 | sourceTree = ""; 130 | }; 131 | B6DDA7B32748BBB3005E239A /* SwiftInterviewQuestionsUITests */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | B6DDA7B42748BBB3005E239A /* SwiftInterviewQuestionsUITests.swift */, 135 | B6DDA7B62748BBB3005E239A /* SwiftInterviewQuestionsUITestsLaunchTests.swift */, 136 | ); 137 | path = SwiftInterviewQuestionsUITests; 138 | sourceTree = ""; 139 | }; 140 | B6DDA7C32748BBEC005E239A /* Ignore */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | B6DDA7902748BBB0005E239A /* AppDelegate.swift */, 144 | B6DDA7922748BBB0005E239A /* SceneDelegate.swift */, 145 | B6DDA7942748BBB0005E239A /* ViewController.swift */, 146 | B6DDA7962748BBB0005E239A /* Main.storyboard */, 147 | B6DDA79C2748BBB2005E239A /* Assets.xcassets */, 148 | B6DDA79E2748BBB2005E239A /* LaunchScreen.storyboard */, 149 | ); 150 | path = Ignore; 151 | sourceTree = ""; 152 | }; 153 | B6DDA7C42748BC0E005E239A /* CoreData */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | B6DDA7992748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodeld */, 157 | ); 158 | path = CoreData; 159 | sourceTree = ""; 160 | }; 161 | B6DDA7C52748BC1A005E239A /* SwiftPlaygroundExamples */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | B6DDA7C72748BC95005E239A /* Loops.playground */, 165 | B6DDA7C62748BC38005E239A /* Variable.playground */, 166 | B6DDA7C82748BCEA005E239A /* Optionals.playground */, 167 | B6DDA7C92748BD25005E239A /* StructAndClass.playground */, 168 | B6DDA7CA2748BD72005E239A /* ArrayEnumDictSet.playground */, 169 | B6DDA7CB2748BDC4005E239A /* InOut.playground */, 170 | B6249744274AEEBC00033BF5 /* Tuples.playground */, 171 | B6249745274AF4B400033BF5 /* Fizz_Buzz_FizzBuzz.playground */, 172 | B6249746274BEFE400033BF5 /* Constants.playground */, 173 | B6249782274DEDE600033BF5 /* GettersAndSetters.playground */, 174 | B6C1D675274F2F330033A254 /* raywenderlichProblems.playground */, 175 | ); 176 | path = SwiftPlaygroundExamples; 177 | sourceTree = ""; 178 | }; 179 | /* End PBXGroup section */ 180 | 181 | /* Begin PBXNativeTarget section */ 182 | B6DDA78C2748BBB0005E239A /* SwiftInterviewQuestions */ = { 183 | isa = PBXNativeTarget; 184 | buildConfigurationList = B6DDA7BA2748BBB3005E239A /* Build configuration list for PBXNativeTarget "SwiftInterviewQuestions" */; 185 | buildPhases = ( 186 | B6DDA7892748BBB0005E239A /* Sources */, 187 | B6DDA78A2748BBB0005E239A /* Frameworks */, 188 | B6DDA78B2748BBB0005E239A /* Resources */, 189 | ); 190 | buildRules = ( 191 | ); 192 | dependencies = ( 193 | ); 194 | name = SwiftInterviewQuestions; 195 | productName = SwiftInterviewQuestions; 196 | productReference = B6DDA78D2748BBB0005E239A /* SwiftInterviewQuestions.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | B6DDA7A52748BBB3005E239A /* SwiftInterviewQuestionsTests */ = { 200 | isa = PBXNativeTarget; 201 | buildConfigurationList = B6DDA7BD2748BBB3005E239A /* Build configuration list for PBXNativeTarget "SwiftInterviewQuestionsTests" */; 202 | buildPhases = ( 203 | B6DDA7A22748BBB3005E239A /* Sources */, 204 | B6DDA7A32748BBB3005E239A /* Frameworks */, 205 | B6DDA7A42748BBB3005E239A /* Resources */, 206 | ); 207 | buildRules = ( 208 | ); 209 | dependencies = ( 210 | B6DDA7A82748BBB3005E239A /* PBXTargetDependency */, 211 | ); 212 | name = SwiftInterviewQuestionsTests; 213 | productName = SwiftInterviewQuestionsTests; 214 | productReference = B6DDA7A62748BBB3005E239A /* SwiftInterviewQuestionsTests.xctest */; 215 | productType = "com.apple.product-type.bundle.unit-test"; 216 | }; 217 | B6DDA7AF2748BBB3005E239A /* SwiftInterviewQuestionsUITests */ = { 218 | isa = PBXNativeTarget; 219 | buildConfigurationList = B6DDA7C02748BBB3005E239A /* Build configuration list for PBXNativeTarget "SwiftInterviewQuestionsUITests" */; 220 | buildPhases = ( 221 | B6DDA7AC2748BBB3005E239A /* Sources */, 222 | B6DDA7AD2748BBB3005E239A /* Frameworks */, 223 | B6DDA7AE2748BBB3005E239A /* Resources */, 224 | ); 225 | buildRules = ( 226 | ); 227 | dependencies = ( 228 | B6DDA7B22748BBB3005E239A /* PBXTargetDependency */, 229 | ); 230 | name = SwiftInterviewQuestionsUITests; 231 | productName = SwiftInterviewQuestionsUITests; 232 | productReference = B6DDA7B02748BBB3005E239A /* SwiftInterviewQuestionsUITests.xctest */; 233 | productType = "com.apple.product-type.bundle.ui-testing"; 234 | }; 235 | /* End PBXNativeTarget section */ 236 | 237 | /* Begin PBXProject section */ 238 | B6DDA7852748BBB0005E239A /* Project object */ = { 239 | isa = PBXProject; 240 | attributes = { 241 | BuildIndependentTargetsInParallel = 1; 242 | LastSwiftUpdateCheck = 1310; 243 | LastUpgradeCheck = 1310; 244 | TargetAttributes = { 245 | B6DDA78C2748BBB0005E239A = { 246 | CreatedOnToolsVersion = 13.1; 247 | }; 248 | B6DDA7A52748BBB3005E239A = { 249 | CreatedOnToolsVersion = 13.1; 250 | TestTargetID = B6DDA78C2748BBB0005E239A; 251 | }; 252 | B6DDA7AF2748BBB3005E239A = { 253 | CreatedOnToolsVersion = 13.1; 254 | TestTargetID = B6DDA78C2748BBB0005E239A; 255 | }; 256 | }; 257 | }; 258 | buildConfigurationList = B6DDA7882748BBB0005E239A /* Build configuration list for PBXProject "SwiftInterviewQuestions" */; 259 | compatibilityVersion = "Xcode 13.0"; 260 | developmentRegion = en; 261 | hasScannedForEncodings = 0; 262 | knownRegions = ( 263 | en, 264 | Base, 265 | ); 266 | mainGroup = B6DDA7842748BBB0005E239A; 267 | productRefGroup = B6DDA78E2748BBB0005E239A /* Products */; 268 | projectDirPath = ""; 269 | projectRoot = ""; 270 | targets = ( 271 | B6DDA78C2748BBB0005E239A /* SwiftInterviewQuestions */, 272 | B6DDA7A52748BBB3005E239A /* SwiftInterviewQuestionsTests */, 273 | B6DDA7AF2748BBB3005E239A /* SwiftInterviewQuestionsUITests */, 274 | ); 275 | }; 276 | /* End PBXProject section */ 277 | 278 | /* Begin PBXResourcesBuildPhase section */ 279 | B6DDA78B2748BBB0005E239A /* Resources */ = { 280 | isa = PBXResourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | B6DDA7A02748BBB2005E239A /* LaunchScreen.storyboard in Resources */, 284 | B6DDA79D2748BBB2005E239A /* Assets.xcassets in Resources */, 285 | B6DDA7982748BBB0005E239A /* Main.storyboard in Resources */, 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | B6DDA7A42748BBB3005E239A /* Resources */ = { 290 | isa = PBXResourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | B6DDA7AE2748BBB3005E239A /* Resources */ = { 297 | isa = PBXResourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | /* End PBXResourcesBuildPhase section */ 304 | 305 | /* Begin PBXSourcesBuildPhase section */ 306 | B6DDA7892748BBB0005E239A /* Sources */ = { 307 | isa = PBXSourcesBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | B6DDA7952748BBB0005E239A /* ViewController.swift in Sources */, 311 | B6DDA79B2748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodeld in Sources */, 312 | B6DDA7912748BBB0005E239A /* AppDelegate.swift in Sources */, 313 | B6DDA7932748BBB0005E239A /* SceneDelegate.swift in Sources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | B6DDA7A22748BBB3005E239A /* Sources */ = { 318 | isa = PBXSourcesBuildPhase; 319 | buildActionMask = 2147483647; 320 | files = ( 321 | B6DDA7AB2748BBB3005E239A /* SwiftInterviewQuestionsTests.swift in Sources */, 322 | ); 323 | runOnlyForDeploymentPostprocessing = 0; 324 | }; 325 | B6DDA7AC2748BBB3005E239A /* Sources */ = { 326 | isa = PBXSourcesBuildPhase; 327 | buildActionMask = 2147483647; 328 | files = ( 329 | B6DDA7B72748BBB3005E239A /* SwiftInterviewQuestionsUITestsLaunchTests.swift in Sources */, 330 | B6DDA7B52748BBB3005E239A /* SwiftInterviewQuestionsUITests.swift in Sources */, 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | }; 334 | /* End PBXSourcesBuildPhase section */ 335 | 336 | /* Begin PBXTargetDependency section */ 337 | B6DDA7A82748BBB3005E239A /* PBXTargetDependency */ = { 338 | isa = PBXTargetDependency; 339 | target = B6DDA78C2748BBB0005E239A /* SwiftInterviewQuestions */; 340 | targetProxy = B6DDA7A72748BBB3005E239A /* PBXContainerItemProxy */; 341 | }; 342 | B6DDA7B22748BBB3005E239A /* PBXTargetDependency */ = { 343 | isa = PBXTargetDependency; 344 | target = B6DDA78C2748BBB0005E239A /* SwiftInterviewQuestions */; 345 | targetProxy = B6DDA7B12748BBB3005E239A /* PBXContainerItemProxy */; 346 | }; 347 | /* End PBXTargetDependency section */ 348 | 349 | /* Begin PBXVariantGroup section */ 350 | B6DDA7962748BBB0005E239A /* Main.storyboard */ = { 351 | isa = PBXVariantGroup; 352 | children = ( 353 | B6DDA7972748BBB0005E239A /* Base */, 354 | ); 355 | name = Main.storyboard; 356 | sourceTree = ""; 357 | }; 358 | B6DDA79E2748BBB2005E239A /* LaunchScreen.storyboard */ = { 359 | isa = PBXVariantGroup; 360 | children = ( 361 | B6DDA79F2748BBB2005E239A /* Base */, 362 | ); 363 | name = LaunchScreen.storyboard; 364 | sourceTree = ""; 365 | }; 366 | /* End PBXVariantGroup section */ 367 | 368 | /* Begin XCBuildConfiguration section */ 369 | B6DDA7B82748BBB3005E239A /* Debug */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | ALWAYS_SEARCH_USER_PATHS = NO; 373 | CLANG_ANALYZER_NONNULL = YES; 374 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 375 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 376 | CLANG_CXX_LIBRARY = "libc++"; 377 | CLANG_ENABLE_MODULES = YES; 378 | CLANG_ENABLE_OBJC_ARC = YES; 379 | CLANG_ENABLE_OBJC_WEAK = YES; 380 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_COMMA = YES; 383 | CLANG_WARN_CONSTANT_CONVERSION = YES; 384 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 385 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 386 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 387 | CLANG_WARN_EMPTY_BODY = YES; 388 | CLANG_WARN_ENUM_CONVERSION = YES; 389 | CLANG_WARN_INFINITE_RECURSION = YES; 390 | CLANG_WARN_INT_CONVERSION = YES; 391 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 392 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 393 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 394 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 395 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 396 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 397 | CLANG_WARN_STRICT_PROTOTYPES = YES; 398 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 399 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 400 | CLANG_WARN_UNREACHABLE_CODE = YES; 401 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 402 | COPY_PHASE_STRIP = NO; 403 | DEBUG_INFORMATION_FORMAT = dwarf; 404 | ENABLE_STRICT_OBJC_MSGSEND = YES; 405 | ENABLE_TESTABILITY = YES; 406 | GCC_C_LANGUAGE_STANDARD = gnu11; 407 | GCC_DYNAMIC_NO_PIC = NO; 408 | GCC_NO_COMMON_BLOCKS = YES; 409 | GCC_OPTIMIZATION_LEVEL = 0; 410 | GCC_PREPROCESSOR_DEFINITIONS = ( 411 | "DEBUG=1", 412 | "$(inherited)", 413 | ); 414 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 415 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 416 | GCC_WARN_UNDECLARED_SELECTOR = YES; 417 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 418 | GCC_WARN_UNUSED_FUNCTION = YES; 419 | GCC_WARN_UNUSED_VARIABLE = YES; 420 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 421 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 422 | MTL_FAST_MATH = YES; 423 | ONLY_ACTIVE_ARCH = YES; 424 | SDKROOT = iphoneos; 425 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 426 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 427 | }; 428 | name = Debug; 429 | }; 430 | B6DDA7B92748BBB3005E239A /* Release */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | ALWAYS_SEARCH_USER_PATHS = NO; 434 | CLANG_ANALYZER_NONNULL = YES; 435 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 436 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 437 | CLANG_CXX_LIBRARY = "libc++"; 438 | CLANG_ENABLE_MODULES = YES; 439 | CLANG_ENABLE_OBJC_ARC = YES; 440 | CLANG_ENABLE_OBJC_WEAK = YES; 441 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 442 | CLANG_WARN_BOOL_CONVERSION = YES; 443 | CLANG_WARN_COMMA = YES; 444 | CLANG_WARN_CONSTANT_CONVERSION = YES; 445 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 446 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 447 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 448 | CLANG_WARN_EMPTY_BODY = YES; 449 | CLANG_WARN_ENUM_CONVERSION = YES; 450 | CLANG_WARN_INFINITE_RECURSION = YES; 451 | CLANG_WARN_INT_CONVERSION = YES; 452 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 453 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 454 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 455 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 456 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 457 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 458 | CLANG_WARN_STRICT_PROTOTYPES = YES; 459 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 460 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 461 | CLANG_WARN_UNREACHABLE_CODE = YES; 462 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 463 | COPY_PHASE_STRIP = NO; 464 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 465 | ENABLE_NS_ASSERTIONS = NO; 466 | ENABLE_STRICT_OBJC_MSGSEND = YES; 467 | GCC_C_LANGUAGE_STANDARD = gnu11; 468 | GCC_NO_COMMON_BLOCKS = YES; 469 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 470 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 471 | GCC_WARN_UNDECLARED_SELECTOR = YES; 472 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 473 | GCC_WARN_UNUSED_FUNCTION = YES; 474 | GCC_WARN_UNUSED_VARIABLE = YES; 475 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 476 | MTL_ENABLE_DEBUG_INFO = NO; 477 | MTL_FAST_MATH = YES; 478 | SDKROOT = iphoneos; 479 | SWIFT_COMPILATION_MODE = wholemodule; 480 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 481 | VALIDATE_PRODUCT = YES; 482 | }; 483 | name = Release; 484 | }; 485 | B6DDA7BB2748BBB3005E239A /* Debug */ = { 486 | isa = XCBuildConfiguration; 487 | buildSettings = { 488 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 489 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 490 | CODE_SIGN_STYLE = Automatic; 491 | CURRENT_PROJECT_VERSION = 1; 492 | DEVELOPMENT_TEAM = 3MSCVD9F92; 493 | GENERATE_INFOPLIST_FILE = YES; 494 | INFOPLIST_FILE = SwiftInterviewQuestions/Info.plist; 495 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 496 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 497 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 498 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 499 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 500 | LD_RUNPATH_SEARCH_PATHS = ( 501 | "$(inherited)", 502 | "@executable_path/Frameworks", 503 | ); 504 | MARKETING_VERSION = 1.0; 505 | PRODUCT_BUNDLE_IDENTIFIER = com.spacemulecode.SwiftInterviewQuestions; 506 | PRODUCT_NAME = "$(TARGET_NAME)"; 507 | SWIFT_EMIT_LOC_STRINGS = YES; 508 | SWIFT_VERSION = 5.0; 509 | TARGETED_DEVICE_FAMILY = "1,2"; 510 | }; 511 | name = Debug; 512 | }; 513 | B6DDA7BC2748BBB3005E239A /* Release */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 517 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 518 | CODE_SIGN_STYLE = Automatic; 519 | CURRENT_PROJECT_VERSION = 1; 520 | DEVELOPMENT_TEAM = 3MSCVD9F92; 521 | GENERATE_INFOPLIST_FILE = YES; 522 | INFOPLIST_FILE = SwiftInterviewQuestions/Info.plist; 523 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 524 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 525 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 526 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 527 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 528 | LD_RUNPATH_SEARCH_PATHS = ( 529 | "$(inherited)", 530 | "@executable_path/Frameworks", 531 | ); 532 | MARKETING_VERSION = 1.0; 533 | PRODUCT_BUNDLE_IDENTIFIER = com.spacemulecode.SwiftInterviewQuestions; 534 | PRODUCT_NAME = "$(TARGET_NAME)"; 535 | SWIFT_EMIT_LOC_STRINGS = YES; 536 | SWIFT_VERSION = 5.0; 537 | TARGETED_DEVICE_FAMILY = "1,2"; 538 | }; 539 | name = Release; 540 | }; 541 | B6DDA7BE2748BBB3005E239A /* Debug */ = { 542 | isa = XCBuildConfiguration; 543 | buildSettings = { 544 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 545 | BUNDLE_LOADER = "$(TEST_HOST)"; 546 | CODE_SIGN_STYLE = Automatic; 547 | CURRENT_PROJECT_VERSION = 1; 548 | DEVELOPMENT_TEAM = 3MSCVD9F92; 549 | GENERATE_INFOPLIST_FILE = YES; 550 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 551 | LD_RUNPATH_SEARCH_PATHS = ( 552 | "$(inherited)", 553 | "@executable_path/Frameworks", 554 | "@loader_path/Frameworks", 555 | ); 556 | MARKETING_VERSION = 1.0; 557 | PRODUCT_BUNDLE_IDENTIFIER = com.spacemulecode.SwiftInterviewQuestionsTests; 558 | PRODUCT_NAME = "$(TARGET_NAME)"; 559 | SWIFT_EMIT_LOC_STRINGS = NO; 560 | SWIFT_VERSION = 5.0; 561 | TARGETED_DEVICE_FAMILY = "1,2"; 562 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftInterviewQuestions.app/SwiftInterviewQuestions"; 563 | }; 564 | name = Debug; 565 | }; 566 | B6DDA7BF2748BBB3005E239A /* Release */ = { 567 | isa = XCBuildConfiguration; 568 | buildSettings = { 569 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 570 | BUNDLE_LOADER = "$(TEST_HOST)"; 571 | CODE_SIGN_STYLE = Automatic; 572 | CURRENT_PROJECT_VERSION = 1; 573 | DEVELOPMENT_TEAM = 3MSCVD9F92; 574 | GENERATE_INFOPLIST_FILE = YES; 575 | IPHONEOS_DEPLOYMENT_TARGET = 15.0; 576 | LD_RUNPATH_SEARCH_PATHS = ( 577 | "$(inherited)", 578 | "@executable_path/Frameworks", 579 | "@loader_path/Frameworks", 580 | ); 581 | MARKETING_VERSION = 1.0; 582 | PRODUCT_BUNDLE_IDENTIFIER = com.spacemulecode.SwiftInterviewQuestionsTests; 583 | PRODUCT_NAME = "$(TARGET_NAME)"; 584 | SWIFT_EMIT_LOC_STRINGS = NO; 585 | SWIFT_VERSION = 5.0; 586 | TARGETED_DEVICE_FAMILY = "1,2"; 587 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftInterviewQuestions.app/SwiftInterviewQuestions"; 588 | }; 589 | name = Release; 590 | }; 591 | B6DDA7C12748BBB3005E239A /* Debug */ = { 592 | isa = XCBuildConfiguration; 593 | buildSettings = { 594 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 595 | CODE_SIGN_STYLE = Automatic; 596 | CURRENT_PROJECT_VERSION = 1; 597 | DEVELOPMENT_TEAM = 3MSCVD9F92; 598 | GENERATE_INFOPLIST_FILE = YES; 599 | LD_RUNPATH_SEARCH_PATHS = ( 600 | "$(inherited)", 601 | "@executable_path/Frameworks", 602 | "@loader_path/Frameworks", 603 | ); 604 | MARKETING_VERSION = 1.0; 605 | PRODUCT_BUNDLE_IDENTIFIER = com.spacemulecode.SwiftInterviewQuestionsUITests; 606 | PRODUCT_NAME = "$(TARGET_NAME)"; 607 | SWIFT_EMIT_LOC_STRINGS = NO; 608 | SWIFT_VERSION = 5.0; 609 | TARGETED_DEVICE_FAMILY = "1,2"; 610 | TEST_TARGET_NAME = SwiftInterviewQuestions; 611 | }; 612 | name = Debug; 613 | }; 614 | B6DDA7C22748BBB3005E239A /* Release */ = { 615 | isa = XCBuildConfiguration; 616 | buildSettings = { 617 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 618 | CODE_SIGN_STYLE = Automatic; 619 | CURRENT_PROJECT_VERSION = 1; 620 | DEVELOPMENT_TEAM = 3MSCVD9F92; 621 | GENERATE_INFOPLIST_FILE = YES; 622 | LD_RUNPATH_SEARCH_PATHS = ( 623 | "$(inherited)", 624 | "@executable_path/Frameworks", 625 | "@loader_path/Frameworks", 626 | ); 627 | MARKETING_VERSION = 1.0; 628 | PRODUCT_BUNDLE_IDENTIFIER = com.spacemulecode.SwiftInterviewQuestionsUITests; 629 | PRODUCT_NAME = "$(TARGET_NAME)"; 630 | SWIFT_EMIT_LOC_STRINGS = NO; 631 | SWIFT_VERSION = 5.0; 632 | TARGETED_DEVICE_FAMILY = "1,2"; 633 | TEST_TARGET_NAME = SwiftInterviewQuestions; 634 | }; 635 | name = Release; 636 | }; 637 | /* End XCBuildConfiguration section */ 638 | 639 | /* Begin XCConfigurationList section */ 640 | B6DDA7882748BBB0005E239A /* Build configuration list for PBXProject "SwiftInterviewQuestions" */ = { 641 | isa = XCConfigurationList; 642 | buildConfigurations = ( 643 | B6DDA7B82748BBB3005E239A /* Debug */, 644 | B6DDA7B92748BBB3005E239A /* Release */, 645 | ); 646 | defaultConfigurationIsVisible = 0; 647 | defaultConfigurationName = Release; 648 | }; 649 | B6DDA7BA2748BBB3005E239A /* Build configuration list for PBXNativeTarget "SwiftInterviewQuestions" */ = { 650 | isa = XCConfigurationList; 651 | buildConfigurations = ( 652 | B6DDA7BB2748BBB3005E239A /* Debug */, 653 | B6DDA7BC2748BBB3005E239A /* Release */, 654 | ); 655 | defaultConfigurationIsVisible = 0; 656 | defaultConfigurationName = Release; 657 | }; 658 | B6DDA7BD2748BBB3005E239A /* Build configuration list for PBXNativeTarget "SwiftInterviewQuestionsTests" */ = { 659 | isa = XCConfigurationList; 660 | buildConfigurations = ( 661 | B6DDA7BE2748BBB3005E239A /* Debug */, 662 | B6DDA7BF2748BBB3005E239A /* Release */, 663 | ); 664 | defaultConfigurationIsVisible = 0; 665 | defaultConfigurationName = Release; 666 | }; 667 | B6DDA7C02748BBB3005E239A /* Build configuration list for PBXNativeTarget "SwiftInterviewQuestionsUITests" */ = { 668 | isa = XCConfigurationList; 669 | buildConfigurations = ( 670 | B6DDA7C12748BBB3005E239A /* Debug */, 671 | B6DDA7C22748BBB3005E239A /* Release */, 672 | ); 673 | defaultConfigurationIsVisible = 0; 674 | defaultConfigurationName = Release; 675 | }; 676 | /* End XCConfigurationList section */ 677 | 678 | /* Begin XCVersionGroup section */ 679 | B6DDA7992748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodeld */ = { 680 | isa = XCVersionGroup; 681 | children = ( 682 | B6DDA79A2748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodel */, 683 | ); 684 | currentVersion = B6DDA79A2748BBB0005E239A /* SwiftInterviewQuestions.xcdatamodel */; 685 | path = SwiftInterviewQuestions.xcdatamodeld; 686 | sourceTree = ""; 687 | versionGroupType = wrapper.xcdatamodel; 688 | }; 689 | /* End XCVersionGroup section */ 690 | }; 691 | rootObject = B6DDA7852748BBB0005E239A /* Project object */; 692 | } 693 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions.xcodeproj/project.xcworkspace/xcuserdata/zachary.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmithZachary/SwiftInterviewProblems/c0639409bd39a3c4401f8db6e9e748b961ed4a6e/SwiftInterviewQuestions/SwiftInterviewQuestions.xcodeproj/project.xcworkspace/xcuserdata/zachary.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions.xcodeproj/xcuserdata/zachary.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ArrayEnumDictSet (Playground) 1.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 14 13 | 14 | ArrayEnumDictSet (Playground) 2.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 15 20 | 21 | ArrayEnumDictSet (Playground).xcscheme 22 | 23 | isShown 24 | 25 | orderHint 26 | 8 27 | 28 | Constants (Playground) 1.xcscheme 29 | 30 | isShown 31 | 32 | orderHint 33 | 10 34 | 35 | Constants (Playground) 2.xcscheme 36 | 37 | isShown 38 | 39 | orderHint 40 | 11 41 | 42 | Constants (Playground).xcscheme 43 | 44 | isShown 45 | 46 | orderHint 47 | 3 48 | 49 | Fizz_Buzz_FizzBuzz (Playground) 1.xcscheme 50 | 51 | isShown 52 | 53 | orderHint 54 | 9 55 | 56 | Fizz_Buzz_FizzBuzz (Playground) 2.xcscheme 57 | 58 | isShown 59 | 60 | orderHint 61 | 10 62 | 63 | Fizz_Buzz_FizzBuzz (Playground).xcscheme 64 | 65 | isShown 66 | 67 | orderHint 68 | 4 69 | 70 | Getters (Playground) 1.xcscheme 71 | 72 | isShown 73 | 74 | orderHint 75 | 11 76 | 77 | Getters (Playground) 2.xcscheme 78 | 79 | isShown 80 | 81 | orderHint 82 | 12 83 | 84 | Getters (Playground).xcscheme 85 | 86 | isShown 87 | 88 | orderHint 89 | 10 90 | 91 | GettersAndSetters (Playground).xcscheme 92 | 93 | isShown 94 | 95 | orderHint 96 | 2 97 | 98 | InOut (Playground) 1.xcscheme 99 | 100 | isShown 101 | 102 | orderHint 103 | 17 104 | 105 | InOut (Playground) 2.xcscheme 106 | 107 | isShown 108 | 109 | orderHint 110 | 18 111 | 112 | InOut (Playground).xcscheme 113 | 114 | isShown 115 | 116 | orderHint 117 | 1 118 | 119 | Loops (Playground) 1.xcscheme 120 | 121 | isShown 122 | 123 | orderHint 124 | 5 125 | 126 | Loops (Playground) 2.xcscheme 127 | 128 | isShown 129 | 130 | orderHint 131 | 6 132 | 133 | Loops (Playground).xcscheme 134 | 135 | isShown 136 | 137 | orderHint 138 | 10 139 | 140 | Old (Playground) 1.xcscheme 141 | 142 | isShown 143 | 144 | orderHint 145 | 20 146 | 147 | Old (Playground) 2.xcscheme 148 | 149 | isShown 150 | 151 | orderHint 152 | 21 153 | 154 | Old (Playground).xcscheme 155 | 156 | isShown 157 | 158 | orderHint 159 | 19 160 | 161 | Optionals (Playground) 1.xcscheme 162 | 163 | isShown 164 | 165 | orderHint 166 | 8 167 | 168 | Optionals (Playground) 2.xcscheme 169 | 170 | isShown 171 | 172 | orderHint 173 | 9 174 | 175 | Optionals (Playground).xcscheme 176 | 177 | isShown 178 | 179 | orderHint 180 | 5 181 | 182 | StructAndClass (Playground) 1.xcscheme 183 | 184 | isShown 185 | 186 | orderHint 187 | 11 188 | 189 | StructAndClass (Playground) 2.xcscheme 190 | 191 | isShown 192 | 193 | orderHint 194 | 12 195 | 196 | StructAndClass (Playground).xcscheme 197 | 198 | isShown 199 | 200 | orderHint 201 | 6 202 | 203 | SwiftInterviewQuestions.xcscheme_^#shared#^_ 204 | 205 | orderHint 206 | 0 207 | 208 | Tuples (Playground) 1.xcscheme 209 | 210 | isShown 211 | 212 | orderHint 213 | 8 214 | 215 | Tuples (Playground) 2.xcscheme 216 | 217 | isShown 218 | 219 | orderHint 220 | 9 221 | 222 | Tuples (Playground).xcscheme 223 | 224 | isShown 225 | 226 | orderHint 227 | 9 228 | 229 | Variable (Playground) 1.xcscheme 230 | 231 | isShown 232 | 233 | orderHint 234 | 2 235 | 236 | Variable (Playground) 2.xcscheme 237 | 238 | isShown 239 | 240 | orderHint 241 | 3 242 | 243 | Variable (Playground).xcscheme 244 | 245 | isShown 246 | 247 | orderHint 248 | 7 249 | 250 | raywenderlichProblems (Playground) 1.xcscheme 251 | 252 | isShown 253 | 254 | orderHint 255 | 12 256 | 257 | raywenderlichProblems (Playground) 2.xcscheme 258 | 259 | isShown 260 | 261 | orderHint 262 | 13 263 | 264 | raywenderlichProblems (Playground).xcscheme 265 | 266 | isShown 267 | 268 | orderHint 269 | 11 270 | 271 | 272 | 273 | 274 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/CoreData/SwiftInterviewQuestions.xcdatamodeld/SwiftInterviewQuestions.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftInterviewQuestions 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import UIKit 9 | import CoreData 10 | 11 | @main 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | // MARK: - Core Data stack 36 | 37 | lazy var persistentContainer: NSPersistentContainer = { 38 | /* 39 | The persistent container for the application. This implementation 40 | creates and returns a container, having loaded the store for the 41 | application to it. This property is optional since there are legitimate 42 | error conditions that could cause the creation of the store to fail. 43 | */ 44 | let container = NSPersistentContainer(name: "SwiftInterviewQuestions") 45 | container.loadPersistentStores(completionHandler: { (storeDescription, error) in 46 | if let error = error as NSError? { 47 | // Replace this implementation with code to handle the error appropriately. 48 | // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 49 | 50 | /* 51 | Typical reasons for an error here include: 52 | * The parent directory does not exist, cannot be created, or disallows writing. 53 | * The persistent store is not accessible, due to permissions or data protection when the device is locked. 54 | * The device is out of space. 55 | * The store could not be migrated to the current model version. 56 | Check the error message to determine what the actual problem was. 57 | */ 58 | fatalError("Unresolved error \(error), \(error.userInfo)") 59 | } 60 | }) 61 | return container 62 | }() 63 | 64 | // MARK: - Core Data Saving support 65 | 66 | func saveContext () { 67 | let context = persistentContainer.viewContext 68 | if context.hasChanges { 69 | do { 70 | try context.save() 71 | } catch { 72 | // Replace this implementation with code to handle the error appropriately. 73 | // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 74 | let nserror = error as NSError 75 | fatalError("Unresolved error \(nserror), \(nserror.userInfo)") 76 | } 77 | } 78 | } 79 | 80 | } 81 | 82 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // SwiftInterviewQuestions 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | 49 | // Save changes in the application's managed object context when the application transitions to the background. 50 | (UIApplication.shared.delegate as? AppDelegate)?.saveContext() 51 | } 52 | 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Ignore/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftInterviewQuestions 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import UIKit 9 | 10 | class ViewController: UIViewController { 11 | 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | // Do any additional setup after loading the view. 15 | } 16 | 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/ArrayEnumDictSet.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | //// - Whats the value of var len and why? 4 | //Q) What are the collection types that are available in swift? 5 | // 6 | //Answer: There are three primary collection types that are available in swift for storing a collection of values. They are dictionaries, sets, and arrays 7 | // 8 | //Arrays: Arrays is an ordered collection of values, which is stored in the same type of values in an ordered list. 9 | //Sets: Sets are an unordered collection of unique values, which are stored in a distinct value of the same type in a collection without any defined ordering. 10 | //Dictionaries: Dictionaries are an unordered collection of Key and value pair associations in an unordered manner. 11 | 12 | //MARK: - Break 13 | var array1 = [1,2,3,4,5] 14 | var array2 = array1 15 | array2.append(6) 16 | var len = array1.count 17 | //how many items will len have and why? 18 | //arrays are value type so when you call a new array it will create a new copy of that array 19 | print(len) 20 | 21 | // Given the array of numbers creat another array called computerNumbers. computedNumbers should multiply each element in the numbers array by the next element. The last element shouldbe multiplied by the first 22 | //e.g. if numbers was equat to [3,1,4,2] -- computedNumbers should equal [3x1. 1x4. 4x2. 2x3] which is [3, 4, 8, 6] 23 | // Hints -- 24 | // multiplication is done using a * not a x 25 | // you shold not have to do the calculations yourself, it should be done by code 26 | // you are NOT allowed to type the numbers 45, 73, 195 or 53 in your solution code 27 | //computerNumbers should be crated as a variable named exactly as you see in the print statement. Do not change the rest of the code. 28 | 29 | //there are multiple ways to solve this, try declaring each position of the array as a variable then try it a different way and wrap it in a for loop -- try it beofre you scroll down for the answers-- if you solved it a different way let me know! 30 | 31 | func excersise() { 32 | let numbers = [45, 73, 195, 53] 33 | 34 | // let computerNumbers = //put code here 35 | 36 | // print(computerNumbers) 37 | } 38 | // 39 | // 40 | // 41 | // 42 | // 43 | // 44 | // 45 | // 46 | // 47 | // 48 | // 49 | // 50 | // 51 | 52 | //answer 53 | //func excersise2() { 54 | // let numbers = [45, 73, 195, 53] 55 | // 56 | // //Create a new array called computedNumbers 57 | // var computedNumbers = [ 58 | // numbers[0] * numbers[1], 59 | // numbers[1] * numbers[2], 60 | // numbers[2] * numbers[3], 61 | // numbers[3] * numbers[0] 62 | // ] 63 | // 64 | // 65 | // print(computedNumbers) 66 | // 67 | //} 68 | // 69 | //excersise2() 70 | //use the array duplicates below and pull out the numbers sorted and with no duplicates. This question was asked to me on a interview. A big trend I have seen is questions pertaining to manipulating arrays. 71 | 72 | var duplicates = [1,1,1,3,4,7] 73 | //answer below ** note there are a lot of wways to do this ** 74 | var nonDuplicares = Set(duplicates) 75 | print(nonDuplicares) 76 | 77 | duplicates.sort(by: >) 78 | //for duplicate in duplicates { 79 | // duplicate. 80 | //} 81 | var newArray: [Int] = [] 82 | var previous: Int = 1 83 | for duplicate in duplicates { 84 | if duplicate != previous { 85 | newArray.append(duplicate) 86 | previous = duplicate 87 | } 88 | } 89 | print(newArray) 90 | //MARK: - In Swift enumerations, whats the differnce between raw calues and associated values? 91 | 92 | //Raw values are used to associate constant (literal) values to enum cases. The value type is part of the enum type, and each enum case must specify a unique raw value (duplicate values are not allowed). 93 | // 94 | //The following example shows an enum with raw values of type Int: 95 | 96 | enum IntEnum : Int { 97 | case ONE = 1 98 | case TWO = 2 99 | case THREE = 3 100 | } 101 | //An enum value can be converted to its raw value by using the rawValue property: 102 | var enumAVar: IntEnum = IntEnum.TWO 103 | var rawValue: Int = enumAVar.rawValue 104 | 105 | //A raw value can be converted to an enum instance by using a dedicated initializer: 106 | 107 | var enumBVar: IntEnum? = IntEnum(rawValue: 1) 108 | 109 | //Associated values are used to associate arbitrary data to a specific enum case. Each enum case can have zero or more associated values, declared as a tuple in the case definition: 110 | enum AssociatedEnum { 111 | case EMPTY 112 | case WITH_INT(value: Int) 113 | case WITH_TUPLE(value: Int, text: String, data: [Float]) 114 | } 115 | //Whereas the type(s) associated to a case are part of the enum declaration, the associated value(s) are instance specific, meaning that an enum case can have different associated values for different enum instances. 116 | 117 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/ArrayEnumDictSet.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/ArrayEnumDictSet.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Constants.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | //constatnts are declared using a let instead of a var 3 | 4 | let greeting = "Hello, playground" 5 | 6 | // umcomment the statement below to see the error 7 | // greeting = "Goodbye, playground" 8 | 9 | //in the below code declare a constant called secondsInAnHour that represents the number of seconds in an hour and assign that number to it on the same line. The data type of the constant should be an Int/ 10 | 11 | func excersise() { 12 | 13 | //write your code here 14 | //when complete the print statement should output how many seconds are in an hour 15 | //hint you may need more than one let statement 16 | 17 | 18 | // Remove the quoations in the print statement to teset your answer 19 | print("secondsInAnHour") 20 | } 21 | excersise() 22 | // 23 | // solution below 24 | // 25 | // 26 | // 27 | // 28 | // 29 | // 30 | // 31 | // 32 | // 33 | func excersiseAnswer() { 34 | let minutesInAnHour = 60 35 | let secondsInAMinute = 60 36 | let secondsInAnHour = secondsInAMinute * minutesInAnHour 37 | 38 | print(secondsInAnHour) 39 | } 40 | excersiseAnswer() 41 | 42 | 43 | 44 | //MARK: - Randomisation Excersise 45 | 46 | 47 | 48 | //You are going to create a password generator using the array bellow called alphabet which contains all the letters in the alphabet. 49 | 50 | //write some code to randomly pick 6 letters out of the alphabet to create a random 6 character password. 51 | 52 | // hint you can add chatracters together with the "+" symbol 53 | 54 | var w = "space" 55 | var x = "outer" 56 | var y = x + w 57 | print(y) 58 | 59 | // note password should be a String of characters like "vacbae" or "abdeds" 60 | 61 | func passwordExcersise() { 62 | let alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] 63 | //there are 26 items in the alphabet array 64 | //hint use Int.random to access a random spot in the array count 65 | 66 | //code here 67 | 68 | //remove "" when you have an answer to check if it prints out the correct answer 69 | print("password") 70 | } 71 | 72 | passwordExcersise() 73 | // 74 | // 75 | // 76 | // 77 | // 78 | // 79 | // 80 | // 81 | // 82 | // 83 | // 84 | // 85 | // 86 | // 87 | // 88 | 89 | func passwordAnswer() { 90 | 91 | let alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] 92 | 93 | let password = alphabet[Int.random(in: 1...26)] + alphabet[Int.random(in: 1...26)] + alphabet[Int.random(in: 1...26)] + alphabet[Int.random(in: 1...26)] + alphabet[Int.random(in: 1...26)] + alphabet[Int.random(in: 1...26)] 94 | 95 | print(password) 96 | 97 | } 98 | 99 | passwordAnswer() 100 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Constants.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Fizz_Buzz_FizzBuzz.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | // for a walk through https://www.skillshare.com/projects/Swift-iOS-Interview-Whiteboard-Questions-Exercises/118472 4 | //MARK: - Fizz, Buzz, Fizz Buzz 5 | 6 | //Divisible by 3 = Fuzz 7 | //Divisible by 5 = Buzz 8 | //Divisible by 3 && 5 = FizzBuzz 9 | 10 | //Conditionals and Loops 11 | // % is remainder below the output is 3 because 10 goes into 13 two times with the remainder equaling 1 12 | 13 % 10 13 | 14 | for i in 1...100{ 15 | switch (i % 3, i % 5) { 16 | case(0,0): 17 | print("FizzBuzz") 18 | case(0,_): 19 | print("Fizz") 20 | case(_,0): 21 | print("Buzz") 22 | 23 | case (_, _): 24 | //prints any number that doesnt meet the above conditions 25 | print(i) 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Fizz_Buzz_FizzBuzz.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/GettersAndSetters.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | //MARK: - Getters 4 | // stored properties 5 | 6 | 7 | let pizzaInnInches: Int = 10 8 | 9 | var numberOSlices: Int = 6 10 | 11 | print(numberOSlices) 12 | 13 | //still a stored property 14 | 15 | 16 | 17 | //computed properties 18 | // has to be a var 19 | // have to explicitly specifiy a data type 20 | 21 | let pizzaInInches: Int = 16 22 | var numberOfPeople: Int = 12 23 | let slicesPerPerson: Int = 4 24 | 25 | var numberOfSlices: Int { 26 | //getter below, it runs to GET us the value of number of slices 27 | get { 28 | return pizzaInInches - 4 29 | } 30 | //MARK: - Setters 31 | set { 32 | //newValue is special 33 | print("numberOfSlices now has a new value which is \(newValue)") 34 | } 35 | } 36 | 37 | var numberOfPizza: Int { 38 | get{ 39 | let numberOfPeopleFedPerPizza = numberOfSlices / slicesPerPerson 40 | return numberOfPeople / numberOfPeopleFedPerPizza 41 | } 42 | set { 43 | let totalSlices = numberOfSlices * newValue 44 | numberOfPeople = totalSlices / slicesPerPerson 45 | } 46 | } 47 | numberOfPizza = 4 48 | print(numberOfPizza) 49 | let a = numberOfSlices * 2 50 | numberOfSlices = 12 51 | print(numberOfPeople) 52 | 53 | 54 | 55 | //MARK: - Painter Challenge 56 | //work out number if buckets of paint i need to paint the wall 57 | // bucket of paint covers 1.5swm 58 | var width: Float = 3.4 59 | var height: Float = 2.3 60 | 61 | 62 | 63 | 64 | var bucketsOfPaint: Int { 65 | let area = width * height 66 | let areaCoveredPerBucket: Float = 1.5 67 | let numberOfBuckets = area / areaCoveredPerBucket 68 | let roundedBUckets = ceilf(numberOfBuckets) 69 | return Int(numberOfBuckets) 70 | } 71 | print(bucketsOfPaint) 72 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/GettersAndSetters.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/InOut.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | //If you use an extra “inout” keyword in a parameter, the original value passed in the parameter will be changed, once the function is executed. 4 | func swapTwoInts(_ a: inout Int, _ b: inout Int) { 5 | let temporaryA = a 6 | a = b 7 | b = temporaryA 8 | } 9 | 10 | //In this function, the values of a and b are swapped. 11 | 12 | var someInt = 3 13 | var anotherInt = 107 14 | swapTwoInts(&someInt, &anotherInt) 15 | print("someInt is now \(someInt), and anotherInt is now \(anotherInt)") 16 | // Prints "someInt is now 107, and anotherInt is now 3" 17 | //Once executed, you can see that the original values have been changed. 18 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/InOut.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Loops.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | //MARK: - For In Loops, While Loops 3 | for number in 1...5 { 4 | //you should probably understand how i am calling number in the print statement below using a \ 5 | print("Hello,\(number)") 6 | } 7 | //if you just want to return what is in the print statement and not print the numbers you can use _ 8 | for _ in 1...5 { 9 | print("Hello") 10 | } 11 | 12 | //further example 13 | 14 | let fruits = ["apple", "pear", "orange"] 15 | let contacts = ["Adam": 123456789, "James": 987654321, "Amy": 912374354] 16 | let word = "Supercalifragilisticexpialdocious" 17 | let halfOpenRange = 1..<5 18 | let closedRange = 1...5 19 | //runs through the array of fruits 20 | for fruit in fruits{ 21 | //set vs array sets wont give a specifc order an array will 22 | print(fruit) 23 | 24 | } 25 | for person in contacts { 26 | print(person.key) 27 | } 28 | 29 | for letter in word { 30 | print(letter) 31 | } 32 | 33 | for number in halfOpenRange { 34 | print(number) 35 | } 36 | for number in closedRange { 37 | print(number) 38 | } 39 | for _ in halfOpenRange { 40 | print("Loop is running") 41 | } 42 | //while loops\ 43 | 44 | //point here is while loops will run till a condition isnt true any more, they can be dangerious if they never are false 45 | 46 | //while true { 47 | // //adding anything here will crash your code because true is always true and it will never stop, go ahead try it 48 | // //print("crash") 49 | //} 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Loops.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Old/interviewproblems.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Old/interviewproblems.playground/playground.xcworkspace/xcuserdata/zachary.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmithZachary/SwiftInterviewProblems/c0639409bd39a3c4401f8db6e9e748b961ed4a6e/SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Old/interviewproblems.playground/playground.xcworkspace/xcuserdata/zachary.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Optionals.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | //MARK: - Write Three Ways to unwrap an optional 4 | 5 | var myString:String? 6 | 7 | //if let unwrapping 8 | 9 | if myString != nil { 10 | print("Value Exists") 11 | } else { 12 | print ("Nil Value") 13 | } 14 | 15 | //guard let unwrapping 16 | var someStr: String? 17 | func unwrap() { 18 | guard let unwrapped = someStr else { return } 19 | print (unwrapped) 20 | } 21 | unwrap() 22 | // set someStr = "Happy" 23 | 24 | // forced unwrapping (unsafe) 25 | 26 | var someBStr: String? 27 | //take away the print statement to see why it is unsafe 28 | print("let unwrapped3 = someStr!") 29 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Optionals.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/StructAndClass.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | var greeting = "Hello, playground" 4 | //MARK: - Struct and Class 5 | //whats the difference? Structs are value types, classes are reference types 6 | //value types(struct, enum) get copied as a new copy when referenced, reference types(class) do not 7 | //https://abhimuralidharan.medium.com/difference-between-a-struct-and-a-class-in-swift-53e08df73714 good article on this 8 | 9 | struct Resolution { 10 | var width = 0 11 | var height = 0 12 | } 13 | let vga = Resolution(width: 640, height: 480) 14 | 15 | vga.width 16 | vga.height 17 | 18 | let rca = Resolution(width: 400, height: 200) 19 | 20 | rca.width 21 | rca.height 22 | vga.width 23 | vga.height 24 | 25 | //class example 26 | class VideoMode { 27 | var resolution = Resolution() 28 | var interlaced = false 29 | var frameRate = 0.0 30 | var name: String? 31 | } 32 | 33 | let hd = Resolution(width: 1920, height: 1080) 34 | var cinema = hd 35 | cinema.width = 2048 36 | let someVideoMode = VideoMode() 37 | let tenEighty = VideoMode() 38 | tenEighty.resolution = hd 39 | print(tenEighty.resolution) 40 | tenEighty.interlaced = true 41 | print(tenEighty.resolution) 42 | tenEighty.name = "1080i" 43 | print(tenEighty.resolution) 44 | tenEighty.frameRate = 25.0 45 | print(tenEighty.frameRate) 46 | // 47 | //This example declares a new constant called tenEighty and sets it to refer to a new instance of the VideoMode class. The video mode is assigned a copy of the HD resolution of 1920 by 1080 from before. It’s set to be interlaced, its name is set to "1080i", and its frame rate is set to 25.0 frames per second. 48 | // 49 | //Next, tenEighty is assigned to a new constant, called alsoTenEighty, and the frame rate of alsoTenEighty is modified: 50 | let alsoTenEighty = tenEighty 51 | alsoTenEighty.frameRate = 30.0 52 | print(alsoTenEighty.frameRate) 53 | print(tenEighty.frameRate) 54 | //Because classes are reference types, tenEighty and alsoTenEighty actually both refer to the same VideoMode instance. Notice that tenEighty.frameRate changed when we asigned 30 to alsoTenEighty.frameRate) 55 | 56 | protocol FullNameable { 57 | var fullName: String { get } 58 | } 59 | 60 | struct Lecturer: FullNameable { 61 | var fullName: String 62 | } 63 | 64 | let lecturer = Lecturer(fullName: "Gift") 65 | 66 | //Second Implementation 67 | struct Student: FullNameable { 68 | let firstName: String 69 | let middleName: String 70 | let lastName: String 71 | 72 | var fullName: String { 73 | return "\(firstName) \(middleName) \(lastName)" 74 | } 75 | } 76 | 77 | let me = Student(firstName: "Abel", middleName: "Agoi", lastName: "Adeyemi") 78 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/StructAndClass.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Tuples.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | // 4 | //Q) What is Tuple? How to create a Tuple in swift? 5 | // 6 | //Answer: A tuple is a group of different values in a single compound value. It is an ordered list of elements. There are two ways of accessing the object data in a tuple i.e. by name or by position. 7 | // 8 | //In swift, a tuple can consist of multiple different types. It can support two values i.e. one of integer type, and the other of a string type. It is a legal command. 9 | 10 | let person = (name: "Bob", age: 57) 11 | print(person.name) 12 | print(person.age) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Tuples.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Variable.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Foundation 3 | var section: String 4 | //MARK: - How to use 5 | //Below are questions I have found through experience or the internet, I put it in playgrounds so you can see the quesitons and answers in action,(in no specifc order) to access certain features take away the print statement to see why the code wont work. hope this helps feel free to add to it, follow me on gitgub.com/smithzachary or instagram/twitter @spacemulecode 6 | //MARK: - Difference between var and let 7 | 8 | // Swift uses type inference to decide which value a variable has 9 | var c: Int = 5 10 | var d = 5 11 | 12 | // these will output the same var = int 13 | // remove the print statement and see that now that c is an Int it cannot be assigned a bool value. This is a static type safety. 14 | print("c = true") 15 | // 16 | 17 | // variables and constants 18 | 19 | var a = 3 20 | let e = 6 21 | a = 7 22 | // setting e again is invalid, remove the print statemnt to see why 23 | print("e = 4") 24 | print(e) 25 | print(a) 26 | 27 | // the follwing challenge comes off of Angela Yu's Udemy Course 28 | // without touching any of the existing code can you write 3 lines of code to switch around the values held inside the two variables a and b? *** and you cannot use any numbers in your code ex. you cant just write aa = 8 and bb = 5 29 | var aa = 5 30 | var bb = 8 31 | //try (aa, bb) = (bb, aa) for a shorter way to do it 32 | //write your code here 33 | //dont change any of the existing code 34 | 35 | 36 | 37 | print("aa: \(aa)") 38 | print("bb: \(bb)") 39 | 40 | // hint introduce another variable ie var cc = ? 41 | // answer below 42 | // 43 | // 44 | // 45 | // 46 | // 47 | // 48 | // 49 | // did you solve it? 50 | 51 | var cc = aa 52 | aa = bb 53 | bb = cc 54 | 55 | // you can add chatracters together with the "+" symbol 56 | 57 | var w = "space" 58 | var x = "outer" 59 | var y = x + w 60 | print(y) 61 | 62 | //MARK: - Will op1 + op2 + op3 be valid? 63 | let op1: Int = 1 64 | let op2: UInt = 2 65 | let op3: Double = 3.34 66 | //Swift doesn’t define any implicit cast between data types, even if they are conceptually almost identical (like UInt and Int). 67 | 68 | //To fix the error, rather than casting, an explicit conversion is required. In the sample code, all expression operands must be converted to a common same type, which in this case is Double: 69 | print("var resultOne = op1 + op2 + op3") 70 | var resultTwo = Double(op1) + Double(op2) + op3 71 | 72 | 73 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/Variable.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/raywenderlichProblems.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | //ensure in the playground setting -----> over there that platform is selected to iOS 4 | 5 | // the following examples come from https://www.raywenderlich.com/762435-swift-interview-questions-and-answers#toc-anchor-001 6 | // #1 7 | //consider the following 8 | 9 | struct Tutorial { 10 | var difficulty: Int = 1 11 | } 12 | 13 | var tutorial1 = Tutorial() 14 | var tutorial2 = tutorial1 15 | tutorial2.difficulty = 2 16 | print(tutorial1) 17 | print(tutorial2) 18 | //What are the values of tutorial1.difficulty and tutorial2.difficulty? Would this be any different if Tutorial was a class? Why or why not? 19 | //tutorial1.difficulty is 1, whereas tutorial2.difficulty is 2. 20 | //Structures in Swift are value types. You copy value types by value rather than reference. The following code creates a copy of tutorial1 and assigns it to tutorial2: 21 | tutorial2 = tutorial1 22 | 23 | //A change to tutorial2 is not reflected in tutorial1. 24 | //If Tutorial were a class, both tutorial1.difficulty and tutorial2.difficulty would be 2. Classes in Swift are reference types. When you change a property of tutorial1, you’ll see it reflected in tutorial2 and vice versa. 25 | // #2 26 | var view1 = UIView() 27 | view1.alpha = 0.5 28 | 29 | let view2 = UIView() 30 | view2.alpha = 0.6 // Will this line compile? 31 | print(view2.alpha) 32 | print(view1.alpha) 33 | 34 | //#3 35 | // 36 | //This complicated code sorts an array of names alphabetically. Simplify the closure as much as you can. 37 | 38 | 39 | var animals = ["fish", "cat", "chicken", "dog"] 40 | 41 | 42 | animals.sort { (one: String, two: String) -> Bool in 43 | return one < two 44 | } 45 | print(animals) 46 | 47 | //answer 48 | //The type inference system automatically calculates both the type of the parameters in the closure and the return type, so you can get rid of them: 49 | animals.sort { (one, two) in return one < two } 50 | print(animals) 51 | //You can substitute the $i notation for the parameter names: 52 | animals.sort { return $0 < $1 } 53 | print(animals) 54 | //In single statement closures, you can omit the return keyword. The value of the last statement becomes the return value of the closure: 55 | animals.sort { $0 < $1 } 56 | print(animals) 57 | //Finally, since Swift knows that the elements of the array conform to Equatable, you can simply write: 58 | animals.sort(by: <) 59 | print(animals) 60 | 61 | var studs = ["abby", "gabe", "xeke", "billy", "don"] 62 | studs.sort { (one: String, two: String) -> Bool in 63 | return one < two 64 | } 65 | print(studs) 66 | studs.append("lin") 67 | print(studs) 68 | studs.sort { (one, two) in return 69 | one < two 70 | } 71 | print(studs) 72 | studs.count 73 | studs.append("hank") 74 | studs.sort(by: <) 75 | 76 | //# 4 77 | 78 | //This code creates two classes: Address and Person. It then creates two Person instances to represent Ray and Brian. 79 | 80 | class Address { 81 | var fullAddress: String 82 | var city: String 83 | 84 | init(fullAddress: String, city: String) { 85 | self.fullAddress = fullAddress 86 | self.city = city 87 | } 88 | } 89 | 90 | class Person { 91 | var name: String 92 | var address: Address 93 | 94 | init(name: String, address: Address) { 95 | self.name = name 96 | self.address = address 97 | } 98 | } 99 | 100 | var headquarters = Address(fullAddress: "123 Tutorial Street", city: "Appletown") 101 | var ray = Person(name: "Ray", address: headquarters) 102 | var brian = Person(name: "Brian", address: headquarters) 103 | 104 | //Suppose Brian moves to the new building across the street; you'll want to update his record like this: 105 | brian.address.fullAddress = "148 Tutorial Street" 106 | 107 | //This compiles and runs without error. If you check the address of Ray now, he's also moved to the new building. 108 | print (ray.address.fullAddress) 109 | 110 | //What's going on here? How can you fix the problem? 111 | //Address is a class and has reference semantics so headquarters is the same instance, whether you access it via ray or brian. Changing the address of headquarters will change it for both. Can you imagine what would happen if Brian got Ray's mail or vice versa? :] 112 | //The solution is to create a new Address to assign to Brian, or to declare Address as a struct instead of a class. 113 | 114 | 115 | 116 | func areTheyEqual(_ x: T, _ y: T) -> Bool { 117 | return x == y 118 | } 119 | 120 | areTheyEqual("ray", "ray") 121 | areTheyEqual(1, 1) 122 | print(areTheyEqual(1, 1)) 123 | 124 | 125 | //#5 126 | //What are the various ways to unwrap an optional? How do they rate in terms of safety? 127 | 128 | // Hint there are 7 129 | 130 | var x : String? = "Test" 131 | 132 | //Forced unwrapping — unsafe. 133 | var a: String = x! 134 | 135 | //Implicitly unwrapped variable declaration — unsafe in many cases. 136 | var d = x! 137 | 138 | //Optional binding — safe. 139 | if let b = x { 140 | print("x was successfully unwrapped and is = \(b)") 141 | } 142 | 143 | //Optional chaining — safe. 144 | var e = x?.count 145 | 146 | //Nil coalescing operator — safe. 147 | var f = x ?? "" 148 | 149 | //Guard statement — safe. 150 | //guard let g = x else { 151 | // return g 152 | //} 153 | 154 | //Optional pattern — safe. 155 | if case let a? = x { 156 | print(a) 157 | } 158 | 159 | //q 6 160 | 161 | // what is the difference between nil and .none 162 | 163 | nil == .none 164 | //there isnt 165 | 166 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestions/SwiftPlaygroundExamples/raywenderlichProblems.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestionsTests/SwiftInterviewQuestionsTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftInterviewQuestionsTests.swift 3 | // SwiftInterviewQuestionsTests 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import XCTest 9 | @testable import SwiftInterviewQuestions 10 | 11 | class SwiftInterviewQuestionsTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestionsUITests/SwiftInterviewQuestionsUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftInterviewQuestionsUITests.swift 3 | // SwiftInterviewQuestionsUITests 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import XCTest 9 | 10 | class SwiftInterviewQuestionsUITests: XCTestCase { 11 | 12 | override func setUpWithError() throws { 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | 15 | // In UI tests it is usually best to stop immediately when a failure occurs. 16 | continueAfterFailure = false 17 | 18 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 19 | } 20 | 21 | override func tearDownWithError() throws { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | func testExample() throws { 26 | // UI tests must launch the application that they test. 27 | let app = XCUIApplication() 28 | app.launch() 29 | 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | func testLaunchPerformance() throws { 35 | if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { 36 | // This measures how long it takes to launch your application. 37 | measure(metrics: [XCTApplicationLaunchMetric()]) { 38 | XCUIApplication().launch() 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftInterviewQuestionsUITests/SwiftInterviewQuestionsUITestsLaunchTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftInterviewQuestionsUITestsLaunchTests.swift 3 | // SwiftInterviewQuestionsUITests 4 | // 5 | // Created by Zach Smith on 11/19/21. 6 | // 7 | 8 | import XCTest 9 | 10 | class SwiftInterviewQuestionsUITestsLaunchTests: XCTestCase { 11 | 12 | override class var runsForEachTargetApplicationUIConfiguration: Bool { 13 | true 14 | } 15 | 16 | override func setUpWithError() throws { 17 | continueAfterFailure = false 18 | } 19 | 20 | func testLaunch() throws { 21 | let app = XCUIApplication() 22 | app.launch() 23 | 24 | // Insert steps here to perform after app launch but before taking a screenshot, 25 | // such as logging into a test account or navigating somewhere in the app 26 | 27 | let attachment = XCTAttachment(screenshot: app.screenshot()) 28 | attachment.name = "Launch Screen" 29 | attachment.lifetime = .keepAlways 30 | add(attachment) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/ArrayEnumDictSet.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | // - Whats the value of var len and why? 4 | 5 | 6 | //MARK: - Break 7 | var array1 = [1,2,3,4,5] 8 | var array2 = array1 9 | array2.append(6) 10 | var len = array1.count 11 | //how many items will len have and why? 12 | //arrays are value type so when you call a new array it will create a new copy of that array 13 | print(len) 14 | 15 | //MARK: - Will op1 + op2 + op3 be valid? 16 | let op1: Int = 1 17 | let op2: UInt = 2 18 | let op3: Double = 3.34 19 | //Swift doesn’t define any implicit cast between data types, even if they are conceptually almost identical (like UInt and Int). 20 | 21 | //To fix the error, rather than casting, an explicit conversion is required. In the sample code, all expression operands must be converted to a common same type, which in this case is Double: 22 | print("var resultOne = op1 + op2 + op3") 23 | var resultTwo = Double(op1) + Double(op2) + op3 24 | 25 | //MARK: - In Swift enumerations, whats the differnce between raw calues and associated values? 26 | 27 | //Raw values are used to associate constant (literal) values to enum cases. The value type is part of the enum type, and each enum case must specify a unique raw value (duplicate values are not allowed). 28 | // 29 | //The following example shows an enum with raw values of type Int: 30 | 31 | enum IntEnum : Int { 32 | case ONE = 1 33 | case TWO = 2 34 | case THREE = 3 35 | } 36 | //An enum value can be converted to its raw value by using the rawValue property: 37 | var enumAVar: IntEnum = IntEnum.TWO 38 | var rawValue: Int = enumAVar.rawValue 39 | 40 | //A raw value can be converted to an enum instance by using a dedicated initializer: 41 | 42 | var enumBVar: IntEnum? = IntEnum(rawValue: 1) 43 | 44 | //Associated values are used to associate arbitrary data to a specific enum case. Each enum case can have zero or more associated values, declared as a tuple in the case definition: 45 | enum AssociatedEnum { 46 | case EMPTY 47 | case WITH_INT(value: Int) 48 | case WITH_TUPLE(value: Int, text: String, data: [Float]) 49 | } 50 | //Whereas the type(s) associated to a case are part of the enum declaration, the associated value(s) are instance specific, meaning that an enum case can have different associated values for different enum instances. 51 | 52 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/ArrayEnumDictSet.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/InOut.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | //If you use an extra “inout” keyword in a parameter, the original value passed in the parameter will be changed, once the function is executed. 4 | func swapTwoInts(_ a: inout Int, _ b: inout Int) { 5 | let temporaryA = a 6 | a = b 7 | b = temporaryA 8 | } 9 | 10 | //In this function, the values of a and b are swapped. 11 | 12 | var someInt = 3 13 | var anotherInt = 107 14 | swapTwoInts(&someInt, &anotherInt) 15 | print("someInt is now \(someInt), and anotherInt is now \(anotherInt)") 16 | // Prints "someInt is now 107, and anotherInt is now 3" 17 | //Once executed, you can see that the original values have been changed. 18 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/InOut.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Loops.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | //MARK: - For In Loops, While Loops 3 | for number in 1...5 { 4 | //you should probably understand how i am calling number in the print statement below using a \ 5 | print("Hello,\(number)") 6 | } 7 | //if you just want to return what is in the print statement and not print the numbers you can use _ 8 | for _ in 1...5 { 9 | print("Hello") 10 | } 11 | 12 | //further example 13 | 14 | let fruits = ["apple", "pear", "orange"] 15 | let contacts = ["Adam": 123456789, "James": 987654321, "Amy": 912374354] 16 | let word = "Supercalifragilisticexpialdocious" 17 | let halfOpenRange = 1..<5 18 | let closedRange = 1...5 19 | //runs through the array of fruits 20 | for fruit in fruits{ 21 | //set vs array sets wont give a specifc order an array will 22 | print(fruit) 23 | 24 | } 25 | for person in contacts { 26 | print(person.key) 27 | } 28 | 29 | for letter in word { 30 | print(letter) 31 | } 32 | 33 | for number in halfOpenRange { 34 | print(number) 35 | } 36 | for number in closedRange { 37 | print(number) 38 | } 39 | for _ in halfOpenRange { 40 | print("Loop is running") 41 | } 42 | //while loops\ 43 | 44 | //point here is while loops will run till a condition isnt true any more, they can be dangerious if they never are false 45 | 46 | //while true { 47 | // //adding anything here will crash your code because true is always true and it will never stop, go ahead try it 48 | // //print("crash") 49 | //} 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Loops.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Old/interviewproblems.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Old/interviewproblems.playground/playground.xcworkspace/xcuserdata/zachary.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmithZachary/SwiftInterviewProblems/c0639409bd39a3c4401f8db6e9e748b961ed4a6e/SwiftInterviewQuestions/SwiftPlaygroundExamples/Old/interviewproblems.playground/playground.xcworkspace/xcuserdata/zachary.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Optionals.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | //MARK: - Write Three Ways to unwrap an optional 4 | 5 | var myString:String? 6 | 7 | //if let unwrapping 8 | 9 | if myString != nil { 10 | print("Value Exists") 11 | } else { 12 | print ("Nil Value") 13 | } 14 | 15 | //guard let unwrapping 16 | var someStr: String? 17 | func unwrap() { 18 | guard let unwrapped = someStr else { return } 19 | print (unwrapped) 20 | } 21 | unwrap() 22 | // set someStr = "Happy" 23 | 24 | // forced unwrapping (unsafe) 25 | 26 | var someBStr: String? 27 | //take away the print statement to see why it is unsafe 28 | print("let unwrapped3 = someStr!") 29 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Optionals.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/StructAndClass.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | var greeting = "Hello, playground" 4 | //MARK: - Struct and Class 5 | //whats the difference? Structs are value types, classes are reference types 6 | //value types(struct, enum) get copied as a new copy when referenced, reference types(class) do not 7 | //https://abhimuralidharan.medium.com/difference-between-a-struct-and-a-class-in-swift-53e08df73714 good article on this 8 | 9 | struct Resolution { 10 | var width = 0 11 | var height = 0 12 | } 13 | let vga = Resolution(width: 640, height: 480) 14 | 15 | vga.width 16 | vga.height 17 | 18 | let rca = Resolution(width: 400, height: 200) 19 | 20 | rca.width 21 | rca.height 22 | vga.width 23 | vga.height 24 | 25 | //class example 26 | class VideoMode { 27 | var resolution = Resolution() 28 | var interlaced = false 29 | var frameRate = 0.0 30 | var name: String? 31 | } 32 | 33 | let hd = Resolution(width: 1920, height: 1080) 34 | var cinema = hd 35 | cinema.width = 2048 36 | let someVideoMode = VideoMode() 37 | let tenEighty = VideoMode() 38 | tenEighty.resolution = hd 39 | print(tenEighty.resolution) 40 | tenEighty.interlaced = true 41 | print(tenEighty.resolution) 42 | tenEighty.name = "1080i" 43 | print(tenEighty.resolution) 44 | tenEighty.frameRate = 25.0 45 | print(tenEighty.frameRate) 46 | // 47 | //This example declares a new constant called tenEighty and sets it to refer to a new instance of the VideoMode class. The video mode is assigned a copy of the HD resolution of 1920 by 1080 from before. It’s set to be interlaced, its name is set to "1080i", and its frame rate is set to 25.0 frames per second. 48 | // 49 | //Next, tenEighty is assigned to a new constant, called alsoTenEighty, and the frame rate of alsoTenEighty is modified: 50 | let alsoTenEighty = tenEighty 51 | alsoTenEighty.frameRate = 30.0 52 | print(alsoTenEighty.frameRate) 53 | print(tenEighty.frameRate) 54 | //Because classes are reference types, tenEighty and alsoTenEighty actually both refer to the same VideoMode instance. Notice that tenEighty.frameRate changed when we asigned 30 to alsoTenEighty.frameRate) 55 | 56 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/StructAndClass.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Variable.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Foundation 3 | var section: String 4 | //MARK: - How to use 5 | //Below are questions I have found through experience or the internet, I put it in playgrounds so you can see the quesitons and answers in action,(in no specifc order) to access certain features take away the print statement to see why the code wont work. hope this helps feel free to add to it, follow me on gitgub.com/smithzachary or instagram/twitter @spacemulecode 6 | //MARK: - Difference between var and let 7 | 8 | var a = 3 9 | let b = 6 10 | a = 6 11 | // setting b again is invalid, remove the print statemnt to see why 12 | print("b = 4") 13 | -------------------------------------------------------------------------------- /SwiftInterviewQuestions/SwiftPlaygroundExamples/Variable.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /interviewproblems.playground.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SmithZachary/SwiftInterviewProblems/c0639409bd39a3c4401f8db6e9e748b961ed4a6e/interviewproblems.playground.zip --------------------------------------------------------------------------------