user689751
user689751

Reputation:

XCode/iOS - reference for ViewController in AppDelegate

It seems to me that my iPad application loads the Storyboard File along with it's ViewController on it's own. I see an entry in the plist file for "Main storyboard file base name".

Coming from a background where I used to create "Empty Application" in Xcode, and I would then create UIViewController along with nib file, instantiate inside

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

and add to the view, and I've reference (variable) to this ViewController object

Now in this "Single View Application", I don't see any reference to the Storyboard based ViewController and I need to have a reference to do some work. please advise.

Upvotes: 4

Views: 3441

Answers (1)

Kyle
Kyle

Reputation: 14656

Check out this question for some sample code about accessing a view controller via the storyboard - Accessing a view controller created through Storyboard using the App Delegate

For a basic answer, you should be able to reference the "window" property. You should be able to use the properties of the "window" reference to reference your other views. There is a "rootViewController" property attached to UIWindow.

UIWindow documentation - http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html

Upvotes: 4

Related Questions