tags:

views:

228

answers:

2

I saw a video tutorial on iphone development without nib files.

As anybody who has programmed without nib files, you will know that you have to remove the nib file from the plist and then add in code in the main.m function UIApplication.

Anyway regarding the following code:

(from app delegate class)

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions { 

// Override point for customization after application launch

// window = [[UIWindow alloc] initWithFrame:[ [UIScreen mainScreen] bounds]];

    window = [[UIWindow alloc] initWithFrame:<#(CGRect)frame#>

    [window makeKeyAndVisible];

    return YES;
}

the line which I have commented out (// windows = [[UIWindows alloc.... etc etc) was taken from the tutorial. Basically the code inititiliases a new instance of UIWindows and sets up the mainscreen etc.

I went into xcode (and used intellisense) and started to type the line """windows = [window = [[UIWindow alloc] initWithFrame:<#(CGRect)frame#>. """

  1. Why couldnt I find the the name initWithFrame argument in the UIWindows class reference document? (I found it in UIView)

  2. And what does CGRect mean? How did the person doing the tutorial know how to add this code """window = [[UIWindow alloc] initWithFrame:[ [UIScreen mainScreen] bounds]];"""" in order to bring up a window.

The point I am making is, shouldnt one be able to program using intellisense and the apple docs? Or do I have to rely on somebody to actually show me how its done?

I started using IBuilder, and to be honest I can build just about anything BUT only by googling and following tutorials. For example making an app with a navigational controller, I could make it, but only if somebody shows me how(of course I can adapt code and put two and two together). If it was for the apple docs and just intelliesnse, I would be lost. Is this the same for everybody else?

I want to learn exactly and perfectly what AND how UIview, UIwindows and UIviewcontoler work, what are they each about? how do they work with each other? any good books some body can recommened me please. I am aware of the Heirgrass, Stephan Kochan and read there books. I have also read the Iphone development book recommened in this forum, but these books just give you the code, they dont explain the how and why?

Maybe i should just read the apple docs , start a small project and just learn from experience.

+2  A: 

To start: CGRect is a structure, that has 4 parameters: x origin, y origin, width, height.

Also: the line

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

allocs and initializes a UIWindow with a frame (a CGRect object) which is the current mainScreen's (a UIScreen object referring to the screen the code is running on) bounds, that is to say its frame. The reason you could not find initWithFrame: in UIWindow docs is because it inherits the method from UIView

Pointers: If you are in Xcode and right click on an API defined class (UIView, UIWindow, CGRect, etc) you can go to find text in documentation and the Apple Docs for the class will pop right up in xcode.

A good guide to start in programming for iOS is here. I also recommend the book Beginning iPhone Development. It is a good starter guide and is very well done.

Jesse Naugher
Actually, the bounds and the frame for a view are different rectangles. The frame incorporates the origin of the view and its overall size, where the bounds typically specifies only the size of the view. If you alter either the position or bounds of a view, the frame is changed to match, and vice versa.
Brad Larson
of course you are right, I was trying to keep it as simple as possible :)
Jesse Naugher
A: 

thank you for your prompt reply.

Do you think the line of code mentioned could be produced by just refering to the apple sdk? or do you think somebody has to actually show me how to use all the classes in conjunction with each other? (i.e. via tutorial or book or example code etc). ?

I know what the code does roughly, should I only be concerned with the result or should I learn exactly what is going on in the code?

would you agree that sometimes its impossible to learn how to use a class or do programmming unless somebody gives you example code?

for example recently I learnt how to use UInavigationcontolller to navigate between different views. I noticed that when I read the code AND exlored IB I understood finally that each View has its own UIViewcontoller (extended class). I didnt pick up this basic fact when I was reading books and tutorials on the internet.

qessar
This should be a comment (or several comments, due to the length) on Jesse's answer, because it's not an answer by itself. You can create the comments and delete this when you're done.
Brad Larson