Another place to review this is chapter 9 , page 247 in Stevenson's Cocoa and Objective-C, Up and Running
Interpreting framework generated code
* application didFinishLaunchingWithOptions is one of the key methods in the MVC design pattern. I thinnnnnkkk it’s the Controller part
* application is a method, it’s passing a parm an object named UIApplication
* NSDictionary is a paramater being passed to the method application didFinishLaunchingWithOptions
* It returns a Boolean value
I don’t quite recall why/how the signifigence of packing all the method calls together, but I remember that there’s something similar done in C++, so look back there
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
The “window” object receives the “addSubview” message
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];
return YES;
}
Searched in help on “addSubView”
Ended up in UIView class reference
The UIView class defines a rectangular area on the screen and the interfaces for managing the content in that area. At runtime, a view object handles the rendering of any content in its area and also handles any interactions with that content. The UIView class itself provides basic behavior for filling its rectangular area with a background color. More sophisticated content can be presented by subclassing UIView and implementing the necessary drawing and event-handling code yourself. The UIKit framework also includes a set of standard subclasses that range from simple buttons to complex tables and can be used as-is. For example, a UILabel object draws a text string and a UIImageView object draws an image.
….
Managing the View Hierarchy
superview property
subviews property
window property
– addSubview:
addSubview:
Adds a view to the end of the receiver’s list of subviews.
- (void)addSubview:(UIView *)view
Parameters
view
The view to be added. This view is retained by the receiver. After being added, this view appears on top of any other subviews.
Discussion
This method retains view and sets its next responder to the receiver, which is its new superview.
Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.
In the viewController.m generated code, the class is declared.
The class inherits from NSObject
@class DeepThoughtsViewController;
@interface DeepThoughtsAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
DeepThoughtsViewController *viewController;
}
· create a pointer to an object of type UIWindow names “window”
· create a pointer to an object “viewController” with a data type “DeepThoughtsViewController”
Next question to remember the answer to (I know I was able to interpret this just a couple of weeks back!)
- The role of the < and >
- I remember that the interface is where we give the preview for the methods
@interface DeepThoughtsAppDelegate : NSObject <UIApplicationDelegate> {
No comments:
Post a Comment