PDA

View Full Version : cocoa - basic principles




dale.albiston
Feb 5, 2007, 01:55 AM
quick question.

Am I right in thinking its normal for each window in a cocoa application to basically have at least two parts, the 'nib' file containing the actual form and a custom 'control' object the handles the interface with the actual application as well as custom function code for the window?

Only asking since I'm more used to vb, which for all its faults is very simple to use.

not knocking xcode, I actually like it just trying to get my head round the way it works.



whooleytoo
Feb 5, 2007, 06:14 AM
More or less true, yes. Of course, you could have several nibs (many applications do); and one controller object per window, or one controller for several windows.

I've always thought it a pity Apple haven't integrated Xcode and IB - having to manually 'sync' between the two (as in, if you create a new outlet in code, you have to drag the file to IB to inform it of the outlet; or if you create an outlet in IB you may need to merge the code files manually, which can be tricky).

robbieduncan
Feb 5, 2007, 07:17 AM
This is part and parcel of the main, root Cocoa design pattern: Model View Controller (http://en.wikipedia.org/wiki/Model-view-controller).

dale.albiston
Feb 5, 2007, 08:20 AM
Cheers I figured this was intentional, and not an oversight, basically cus while its long winded it actually works well.

just nice to know I'm reading it right.

and the tip on how to tell IB about new outlets etc is most welcome, i've been adding them manually in both IB and XCode.... it works but.. um.. well my goof.

kinda like the 'merge' feature, which appears to hate me personally. but I'll get there.

kpua
Feb 5, 2007, 09:37 AM
and the tip on how to tell IB about new outlets etc is most welcome, i've been adding them manually in both IB and XCode.... it works but.. um.. well my goof.

I personally prefer the drag-the-header-file-onto-the-IB-window method to do this myself. For me, it's easier to just create the outlets and actions in code and have IB create all the entries its little tableviews for me, rather than do it the other way around which is somewhat clunky and requires the whole hassle of merging. This isn't the easiset thing in the world, but considering the options, that's what I always do.