Last active
August 29, 2015 14:17
-
-
Save 98chimp/b4692e92f8d0dabd3b62 to your computer and use it in GitHub Desktop.
Week02 - D01 Questions
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
| Q1. First, the view component of the MVC (i.e., LLView) should not be declaring a property that is of UIViewController type | |
| (i.e., @property (nonatomic, weak) UIViewController* parentViewController;). Instead, the LLView should have a protocol that is potentially delegated to UIViewController in order to achieve separation of concerns. Secondly, the method to configure the LLObject appears to be stting up the model and as such it needs to be declared elsewhere to separate Model from View altogether. | |
| Q2.A.i) atomicity (i.e., atomic vs. nonatomic) deals with how properties behave in a multi-threaded environment. To avoid potential data curroption resulting from the de-coupling of the getter and setter methods for the property, the use of an atomic attibute for a property is advisable. Conversely, in a single-threaded setting the nonatomic attribute is often used. | |
| Q2.A.ii) Weak vs strong: The strong attribute creates an owning relationship to whatever object is assigned to the property. This is the implicit behavior for all object properties, which is a safe default because it makes sure the value is retained in memory as long as it’s assigned to the property. Conversely, the week attribute allows for the 2nd object to establish an is-owned-by relationship to the first object and prevent a situation of coupling together of the two objects in memroy. | |
| Q2.A.iii) The assign attribute doesn’t perform any kind of memory-management call when assigning a new value to the property. This is the default behavior for primitive data types (e.g., int, bool, etc.). | |
| Q2.B. Bacasue changing the value from the properly will call all the necessary KVO methods so that other classes can get notified when the value changes. | |
| Q2.C. The property attribute of a delegate should be set to weak because it is owned by the class which is delegating a protocol to it. | |
| Q3. It looks for which view a given IBAction is pointing to. | |
| Q4.A. In situations when a phone or FaceTime call received, when a push notification is received, or when the user presses the home button. | |
| Q4.B. The appDelegate will detect these events or state changes and report them to the App singleton. For example the two methods | |
| - (void)applicationWillResignActive:(UIApplication *)application; followed by | |
| - (void)applicationDidEnterBackground:(UIApplication *)application; | |
| Q.5. (from Apple Documentation) | |
| i) - isFirstResponder; | |
| Returns a Boolean value indicating whether the receiver is the first responder. | |
| ii) - isNextResponder; | |
| Returns the receiver's next responder, or nil if it has none. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment