My Blog List

Friday, June 3, 2011

Reading Notes: Is it Magic? Is it happening in the framework code? Initialization of Window

 Exactly how 'window' is being initialized is bugging me. I'm not seeing an obvious place where the object is instantiated. 

Maybe because it's happening in the framework?

Or maybe because all the business of @synthesize and @property doing the accessing for me?

The author says that DeepThoughtsAppDelegate.m is initializing window. Is initialization happening by using 
·      @implentation directive?
o    Or
·      with the @synthesize window ?

·      Searched on ‘alloc’ and ‘init’ in the code. I don’t see init

·      Come back to this

·       getting used. Is there some magic that @synthesize does?

The @synthesize directive automatically generates the setters and getters for us, so all we have to implement for this class is the dealloc method. ..Accessors will only be generated if they don't already exist, so feel free to specify @synthesize for a property, then implement your custom getter or setter if you want. The compiler will fill in whichever method is missing.
…. Snip from the wikipedia online tutorial
a mutator method is a method used to control changes to a variable. The mutator method, sometimes called a "setter", is most often used in object-oriented programming, in keeping with the principle of encapsulation. According to this principle, member variables of a class are made private to hide and protect them from other code, and can only be modified by a public member function (the mutator method), which takes the desired new value as a parameter, optionally validates it, and modifies the private member variable.
Often a "setter" is accompanied by a "getter" (also known as an accessor), which returns the value of the private member variable…..


No comments:

Post a Comment