How do UIView(s) and UIViewController(s) communicate ?

Discussion in 'iOS Programming' started by zaxonus, Dec 23, 2010.

  1. zaxonus, Dec 23, 2010
    Last edited: Dec 24, 2010

    zaxonus macrumors newbie

    Joined:
    Dec 23, 2010
    #1
    Hello,

    Like many other people starting on iPhone/Xcode I am having trouble feeling comfortable with UIView and UIViewController.

    Here is my present question. Let us say I have the four following objects :
    XView and YView both of type UIView, and their respective controllers XViewCtrl and YViewCtrl both of type UIViewController.
    How do those objects communicate together in the standard way ? Do they use specific methods ? Or see each other's public variables ?
    What is the exact syntax to use ?

    I read on the net that UIViewController objects are supposed to know about UIView objects and not the other way around.
    But that does not tell me how these UIViewController objects know about those UIView objects.

    Thanks for any help.
     
  2. vocaro macrumors regular

    Joined:
    Mar 5, 2004
    #2
    Get a book on iPhone programming and read about IBAction and IBOutlet. These are how UIViewControllers know about UIView objects (assuming Interface Builder is used to design the views).
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    Start with the class reference for UIViewController:
    http://developer.apple.com/library/...ViewController_Class/Reference/Reference.html

    Look under the heading "Managing the View". Notice the view property, whose type is UIView. That's how a UIViewController knows about its UIView object.

    Next, scroll closer to the top of the class reference for the heading "Using View Controllers With Other View Controllers". It tells you a few things about how one view controller knows about other view controllers. It's not the complete list of every possible relationship between view controllers, but it does list some of the most common relationships.

    There is also a link in the left-hand column called "View Controller Programming Guide for iOS". You should read that in addition to reading the class reference doc.

    If something above doesn't make sense (including concepts encountered in reading the docs), then you need to go back and study the fundamentals. If you haven't studied any fundamentals yet, then you should do that first.

    Finally, the doc for the UIViewController class reference should also be in Xcode's docset for iOS, which you can access using Xcode's Help menu. If you don't know how to use Xcode's Help menu, you should practice using it to look things up, because you will be doing it a lot.
     

Share This Page