Combining Storyboards with traditional nib-files?

Discussion in 'iOS Programming' started by Danneman101, Jan 29, 2012.

  1. Danneman101 macrumors 6502

    Joined:
    Aug 14, 2008
    #1
    Is it possible to combine Storyboards with traditional nib-files?

    The reason I'm asking is that storyboards do not expose the AppDelegate, and if you wish to call a method in another class from the AppDelegate it's excruciatingly painful (exampel: http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1).

    I know it's possible to use them both separately in a single project, but how can I make them interact?

    I was thinking the nib-file, exposing the AppDelegate, could connect to the relevant views in the storyboard that it wants to call methods from.

    Am I just dreaming?
     
  2. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #2
    I've now spent a considerable amount of time googling the issue, and have found no apparent solution, so I'm guessing this is out of the question.

    This is how you can do it programmatically, however (look at the bottom as to skip my frustrated flailing ;) ):

    http://forums.macrumors.com/showthread.php?t=1289152
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    It is, similar to how it's possible to combine nib-files with programmatically defined user-interface.

    To be clear, that issue you had in your other thread was more about getting access to a viewController from within a storyboarded app than it was about combining storyboards and NIBs.
     
  4. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #4
    What I really meant was if it's possible to link, for instance, an outlet in the nib-file exposing AppDelegate, to an object in another view that is exposed in the storyboard. Is that really possible without doing it programmatically similarly to the link I've attached?
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    I'm not sure what you mean by this. Care to elaborate? AppDelegate is a singleton that is available throughout your code.
     
  6. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #6
    Well, for instance, even if you have both a nib-file that exposes the app-delegate (and in the AppDel.h you have an iboutlet for a view called, say, firstViewController), and you also have a storyboard (that by default excludes the app-delegate object), you can't connect the outlet firstViewController from the nib-file to the firstViewController-object in the storyboard using the connection inspector.

    But I think I missed an obvious solution: what if you created a new ViewController-object in the nib-file and linked it to the FirstViewController-class, and did the connection to the firstViewController here in the nib-file's connection inspector. That way you'd have two representations of the firstViewController-object, one inside the nib-file and one inside the storyboard, but the connections would still be made. I'll try it out when I get home, but would it work or will the xcode debugger complain about a duplicated object or something?
     

Share This Page