Lefora Free Forum
Loading
872 views

Cocoa MainWindow.xib vs iPhone Window application MainWindow.xib

Page 1
1–2
rookie - member
2 posts

Hello, i am a complete noob regarding development on the mac/iphone, and i'm starting to learn (with delight i must say) the various programming topics. However, if i get stuck on something, i find it hard (if not impossible) to just keep going. I have created two simple applications in Xcode, an iPhone Window app, and a Cocoa app, and took a look at their MainWindow.xib files. I want to understand completely what is going on in there, before continuing further. Now, there is this File's Owner icon, that is the UIApplication or NSApplication instance in both xib files. There is also a First Responder icon, and a Delegate in both xibs. However, in the cocoa xib, there is also an Application icon, that probably is the same object as File's Owner. Am i correct ? If yes, why is it there, an not in iphone's xib ? Or is it something else ?

Thank you

?
288 posts

Hi J

Apologies for not replying sooner - I have no idea how I missed your question.

The NIB is a mysterious object.  It has resources of course - very much like a Windows .rc ( and .res) file.  So it has windows and menus and stuff like that.  However it has something which is not like Windows at all.  It 'pretends' to have objects inside it - and that's what the Delegate, File's Owner and so on are.

If fact, of course, the NIB doesn't have objects inside it.  At run time, the objects that correspond to the nib objects are build and awakeFromNib call is invoked on the object.  A very common pattern in Cocoa is to have a 'Controller' object to manage a window.  The UI is built, your 'Controller' is created in memory and then you're told (via the awakeFromNib) call that you're alive and can talk to your UI.

This takes a little practice and I think most folks feel quite uncomfortable with this concept at first.

I have written some tutorials at http://clanmills.com/articles/cocoatutorials/  The tutorial "Diary" deals quite a lot with the NIB, however I would not recommend you tackle that one first.  Start with "Clock" and BYOB - you'll be able to do them in about an hour and maybe that'll help you build confidence to go further.

I have personally never looked at the iPhone SDK - however I'm sure that understanding Cocoa is 90% about Cocoa, and 10% about the classes you want to use.  I'll be happy to demonstrate and discuss any of the tutorials on-line (Skype 'clanmills').  You can VNC to my computer and I can explain and demo this stuff to you.

It's easy to get a bit lost in Cocoa land - however you'll find the learning effort will reap rewards.

__________________
Page 1
1–2

Locked Topic


You must be a member to post in this forum

Join Now!