MrDB
MrDB

Reputation: 659

IBAction/IBOutlet - Model View Controller

In the MVC design pattern, which class file (appdelegate, viewcontroller etc) is best suited for these IBOutlet/IBAction scenarios?:

  1. IBAction (e.g. Show Menu) to be triggered by UIButton press event?
  2. IBOutlet to manipulate a UI elements properties (e.g. Hide Menu)?

A poke around Apple's sample code seems to show IBOutlets existing in the AppDelegate and/or the ViewController, and IBActions being in the ViewController only.

Any inputs on which way best aligns with the "right way"/MVC design patterns?

Thanks!

Upvotes: 0

Views: 782

Answers (1)

Cory Imdieke
Cory Imdieke

Reputation: 14808

You're going to want both of those things in the View Controller file that is attached to that nib. So if you have a MainMenuViewController.h/.m and MainManuViewController.xib you'll want to put the actions and outlets in there.

The App Delegate you really only want to use to set up some things on launch (like your root views) or do some app-wide actions, like saving or loading data on launch or quit. The outlets in the App Delegate are usually in the MainWindow.xib file, and are for initial app setup.

Upvotes: 1

Related Questions