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

View Single Post
Old 09-15-2008, 09: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
 

» Advertisements
» Stats
Members: 158,736
Threads: 89,191
Posts: 380,535
Top Poster: BrianSlick (7,129)
Welcome to our newest member, wrapsol
Powered by vBadvanced CMPS v3.1.0

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