Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 09-15-2008, 08:06 PM   #16 (permalink)
amirbudicecep
New Member
 
Join Date: Sep 2008
Posts: 8
Default

Quote:
Originally Posted by bhil View Post
Actually, I played with it some more, and it appears you don't have to do any of the IBOutlet stuff, you can just use
Code:
[self navigationController]
to access the navigation controller containing the ViewController you are in.

The more I use it the more I hate using IB with the iPhone SDK. It is completely inconsistent in how things are done, with some requiring outlets and some not.
My initial impression is also similar. But after [re]reading the official guides for the nth times, they give more sense every time (the guides are definitely NOT the easiest or best-seller reading materials).

navigationController is a property of UIViewController. The following is quoted from UIViewController reference (requires Apple ID):
navigationController
A parent or ancestor that is a navigation controller. (read-only)

@property(nonatomic, readonly, retain) UINavigationController *navigationController

Discussion
Only returns a navigation controller if the view controller is in its stack. This property is nil if a navigation controller cannot be found.
So, as long as the view controller is in the navigation controller's stack (being 'pushed' to the stack via pushViewController:animated: ), it will have a reference back to the navigation controller. Similar to this are tabBarController and parentViewController (it can be the controller that presents "self" as modal, or the navigation controller, or the tab bar controller, or nil). For these "parents", we don't need to create IBOutlets to refer to them.

Quote:
Originally Posted by rapidbunny View Post
is this similar to "this" in java? but then "this" in java only applies to the object you are on......what is "self" exactly referring to? the delegate?
If you're using it inside the DetailedViewController class, then "self" is referring to its instance/object. DetailedViewController itself is a subclass of UIViewController. So, if it's been pushed to the navigation controller's stack previously, [self navigationController] (or self.navigationController) will refer to its "parent", i.e. the navigation controller.
amirbudicecep is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 261
23 members and 238 guests
Affan, appbox, Batman, beginer2007, Blitfast, calvin464, computermatt, dave1619, dre, e747, Eagle11, iGeorG, itzdark, Kalimba, LemonMeringue, mlfarrell, phaseIV, pstool, rdfrahm, ThirtyOne, Varras, williamlegate, wuf810
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,214
Threads: 38,997
Posts: 171,053
Top Poster: smasher (2,569)
Welcome to our newest member, Varras
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:19 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.