Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-04-2009, 07:29 PM   #1 (permalink)
New Member
 
Join Date: Mar 2009
Location: Rochester, MN
Posts: 3
Default Apple docs incorrect? - IB & Navigation

First the question:
As far as I understand, the xib File's Owner needs to be set to the class of the view controller. All the I/O needs to go through the File's Owner object, correct?

Here's the background to my confusion.

Document:
"Interface Builder User Guide"
Section:
"Configuring the Views for Additional Navigation Levels"

This section describes how to add subviews.

1. Create a new nib file using the Cocoa Touch View template.
2. Add a view controller object to the top level of the nib file.
3. Set the class of the view controller to your custom class, as described in “Setting the Class of an Object” (page 117).

Then they go on about adding a View Controller and embedding items into it.
bgrupczy is offline   Reply With Quote
Old 03-04-2009, 08:59 PM   #2 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
Default

I don't normally do it the way they describe in that section. I think it might not work.

Not sure why they don't show the usual way that it's done.
PhoneyDeveloper is offline   Reply With Quote
Old 03-04-2009, 09:01 PM   #3 (permalink)
Tutorial Author
 
Join Date: Jan 2009
Posts: 144
Default

Yes, the files owner class needs to be set to your custom class otherwise it will just be a generic NSObject and you wont have access to the IBoutlets and other methods in the custom class.
meowmix23F is offline   Reply With Quote
Old 03-04-2009, 09:54 PM   #4 (permalink)
New Member
 
Join Date: Mar 2009
Location: Rochester, MN
Posts: 3
Default

I can't wrap my head around why they would leave the documentation wrong for so long. The method they're describing just will not work. I even searched around for some kind of addendum. Nope.

Thanks for the quick replies.
bgrupczy is offline   Reply With Quote
Old 03-05-2009, 02:02 AM   #5 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by bgrupczy View Post
First the question:
As far as I understand, the xib File's Owner needs to be set to the class of the view controller. All the I/O needs to go through the File's Owner object, correct?
Not always - "File's Owner" should be set to the type of the object that "initWithNib" is being called on. That object should be "outside" of the nib.

For most of Apple's sample templates, MainWindow.xib points to a UIApplication for its owner. You never see the code that calls initWithNib here- it's hidden inside the default behavior.

If you're calling initWithNib yourself, you should make sure the nib file has the correct type set for the owner, or the connections will not be made. If you're using the code

[[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];

then File's Owner should be a "MainViewController."
__________________

Free Games!
smasher is offline   Reply With Quote
Reply

Bookmarks

Tags
file's owner, viewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 269
19 members and 250 guests
ADY, Alsahir, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, Herbie, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, Robiwan, smethorst, spiderguy84, twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:42 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0