-
-
Save Viranchee/74c5c474bdef2d5ff560dc32e60434b3 to your computer and use it in GitHub Desktop.
Viranchee_edits_4_Murli_Articles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* https://medium.com/@MuraliKathir/ios-developer-interview-tips-questions-part-1-8e76cc8995a4 | |
For Interview Questions | |
10. What is an Offset | |
17. | |
18. Blocks | |
22. Different type of Initializers | |
23. Bounding Box | |
Almost never asked: | |
Viper architecture, role of Interactor in Viper is far from good | |
Bindings? Better said as KVO | |
Replace Dependency Inversion with `Protocol oriented programming` or ask about `Delegates` | |
*/ | |
/* | |
For Interview Answers Part 2 | |
Associated Type Enum bad example given | |
enum X { 10,8, "Hello"} DOES NOT COMPILE | |
Explanation is not upto mark and candidate may get rejected after going through this article | |
Stored and Computed property explanation: | |
Value is stored in memory as part of a stored property. In case of enums with associated type, the value is stored in that speicific case. | |
For Computed properties, they behave as functions/closures, of type `() -> Property` and when called, rely on logic written in that function | |
An extension can not host a stored property as that means modifying size of that Struct/Enum/Class/Protocol for a compiled language (Swift, in our case). | |
An extension can host computed properties, and closures in Swift are saved in Heap memory | |
Note: Functions and Closures are similar in terms of functionality, Functions have an advantage of having a name, while closures are anonymous functions | |
In this blob of text, functions and closures are used interchangably and mean the same | |
Trailing closure is usually not asked | |
Escaping closures are not complex. | |
In Closures (read Functions for simplicity), the data is `by default, NON ESCAPING`. What it means is, the values inside the function get destroyed after it finishes execution | |
func add(x: Int, y: Int) -> Int { let square = x * x; return x+y; } | |
When this `add` function (read as closure) executes, memory is reserved for `square` variable of type Int (Int64, auto type annotation) and when value is returned, the `square` variable gets destroyed | |
If you want to extend it's lifetime, you want it to live after the function has finished execution, you mark it as @escaping | |
Read on documentation for more clear usage | |
StrongWeakUnowned: When you hold a variable to a reference type (classes, closures, protocols(correct me)), it's reference count increases by one | |
Setting the variable to a Weak or Unowned type tells the compiler to not increase it's reference count | |
Rename AutomaticUnwrapping to ImplicitlyUnwrappedOptionals. | |
ForcedUnwrapping will crash at runtime if value is Nil | |
Optional Binding: Nested optionals (A?.B?.C) will return a single level of optional(C?) | |
KVO-KVC: Add proper names. KVO : Key Value Observing | |
CoreData, SQL, Realm: The topic is vast, please make another blog post for that | |
*/ | |
/* Part 3 | |
Deep and Shallow Copy: Add example | |
isUniquelyReferenced(inout: AnyObject) | |
Class methods and Instance methods section is a confusing section, solution: | |
Functions living in class/struct/enum/protocols are commonly referred to as methods, as good as writing `class` in front of them for clarity, or for specifying some protocol requirements | |
Static functions and variables are shared across all classes of that type | |
When you declare a method, it defaults to a `class` method | |
Static & Dynamic dispatch is a whole awesome topic, please check `WWDC 16 Protocol & Value Oriented Programming` session | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment