- Explain how the memory management works on iOS
- What is a weak qualifier and when should it be used
- Explain the MVC pattern
- Explain the MVVM pattern
- What are the property qualifiers that define the memory management behaviour?
- Describe ARC
- What’s the main problem with ARC?
- Explain what is dependency injection
- Is a block an object?
- Describe the behavior of objc_msgSend?
- Delegation is a common pattern on iOS and historically well-known, give an example
- When are the objects deallocated?
- Why do we use the * for the objects in Objective-C?
- Describe yourself using JSON
- Do you know how autolayout works under the hood?
-
-
Save rpbaltazar/ae5fa788c4d9d7128fc0f8aad659bf1a to your computer and use it in GitHub Desktop.
Question 1:
In Ruby, the memory management is taken care by the garbage collection
(which will Sweep
the unused, garbage objects back onto the free list when there are no objects remain on the free list).
In IOS, if you
- need to keep an object around,
you must retain it unless you know it's already been retained for you. - want to get rid of an object that you own,
you need to release it, unless you know it's already been released for you
Hence, ARC is introduced in the way that, if no strong pointer
points to it (retain count = 0), the object will be destroyed.
Notes for Question 4.
MVVM stands for Model-View-ViewModel
It is somehow similar to MVC pattern, being sometimes considered da variation of it, but this pattern suggests the implementation of a ViewModel to make the translation of the Model's data into the data needed for the View. In this way, it allows yet another level of separation of concepts.
Notes for Question 5:
http://rdcworld-iphone.blogspot.sg/2012/12/variable-property-attributes-or.html
Question 8
Dependency injection means giving an object its instance variables.
Fishing Examples
Let's imagine that you want to go fishing:
- Without dependency injection, you need to take care of everything yourself. You need to find a boat, to buy a fishing rod, to look for bait, etc. It's possible, of course, but it puts a lot of responsibility on you. In software terms, it means that you have to perform a lookup for all these things.
- With dependency injection, someone else takes care of all the preparation and makes the required equipment available to you. You will receive ("be injected") the boat, the fishing rod and the bait - all ready to use.
Why using it?
It can make testing lots easier
- Without Dependency Injection
Application needs Foo (e.g. a controller), so:
Application creates Foo
Application calls Foo
Foo needs Bar (e.g. a service), so:
Foo creates Bar
Foo calls Bar
Bar needs Bim (a service, a repository, …), so:
Bar creates Bim
Bar does something
- With Dependency Injection
Application needs Foo, which needs Bar, which needs Bim, so:
Application creates Bim
Application creates Bar and gives it Bim
Application creates Foo and gives it Bar
Application calls Foo
Foo calls Bar
Bar does something
http://www.jamesshore.com/Blog/Dependency-Injection-Demystified.html
http://stackoverflow.com/questions/130794/what-is-dependency-injection
Question 9
Blocks are Objective-C objects, which means they can be added to collections like NSArray or NSDictionary.
Question 3:
The bank analogy makes it easier to grasp.
http://zenofcoding.com/2009/01/06/another-way-to-think-about-mvc/