★ TouchArcade needs your help. Click here to support us on Patreon.

Do I have the right idea?

04-10-2011, 04:20 AM
Joined: Nov 2009
Posts: 30
Do I have the right idea?

I'm woking my way through "Beigining iPhone 4 Programming", and I would like to know I've got the right idea about so OOP Terms etc.
I've posted on the books forum, but I'd like to post here, too.
Since re-wording it wouldn't really help, I'll just post what I put there, and link you to the project I've done so far
I'm just coming to the end of Chapter 6: Multiview Apps, and I'd like to clarify that I have it understood.
Please correct me if I'm wrong, I really want to understand this!
The "View" the user seems is MainWindow.xib, which on it's own would be blank, apart from the toolbar along the bottom. On run time, another view is loaded into the MainWindow view, and becomes a subview of it (Sub-class, too? I'm not good with what a class is), in this case we use BlueView.xib. From here, the button can be pressed to bring up a UIAlert, this I'm Ok with. When the "switch views" button is pressed, the "active" view is switched to YellowView.xib, whilst BlueView.xib is kept in the background, waiting to be switched again. At this point, BlueViws.xib is NOT viewable (IE, not being YellowView.xib, but simple not there at all).
Assuming that's all right, can someone explain how the .h/.m files are "linked" to the .xib files, and why we had to ctrl + drag from Files Owner to View to establish some sort of connection?
Files: http://cl.ly/5rDl
Thanks for any help.
Joseph Duffy
04-10-2011, 10:01 AM
Joined: Mar 2011
Location: In a car
Posts: 324
Well the idea is this, when you create a new class(.h,.m) you are asked if you want to also create a Nib(.xib) file, what this does is that it will link the nib to your class!
If you open a nib file and you click on the file's owner you will see with what class it is linked, and you can also change that and link it to whatever!
The View contains all your elements, you must connect it to your class!The same you do with other outlets, like buttons segmented control, etc.This way xcode knows about what element you are talking about!

My Twitter:@Tudor