Switch Nibs

Discussion in 'iOS Development' started by startrees, Aug 11, 2010.

  1. startrees

    startrees Member

    Joined:
    Nov 29, 2008
    Messages:
    223
    Likes Received:
    0
    Device:
    iPad 2 (White)
    Hey people

    I have been trying to switch NIB files and every time it just crashes. Any help?

    my code:
    it runs with no errors or warnings...
    Thank you for any help!

    Please Register or Log in to view images

  2. Freerunnering

    Freerunnering Member

    Joined:
    Sep 1, 2009
    Messages:
    296
    Likes Received:
    0
    Device:
    4G iPod touch
    If your trying to switch between 2 nib files why is second view controls nib file set to nil?
  3. startrees

    startrees Member

    Joined:
    Nov 29, 2008
    Messages:
    223
    Likes Received:
    0
    Device:
    iPad 2 (White)
    I tried it the other but it didn't work so I tried this
  4. zombie boy99

    zombie boy99 Well-Known Member

    Joined:
    Aug 11, 2010
    Messages:
    7,730
    Likes Received:
    276
    Device:
    iPhone 5S
    I know I sound stupid but what are nib files?
  5. startrees

    startrees Member

    Joined:
    Nov 29, 2008
    Messages:
    223
    Likes Received:
    0
    Device:
    iPad 2 (White)
    SecondView is the one I want to switch to
  6. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    @OP/startrees: You need to give us more context. Theoretically, what you're doing is perfectly valid, except that you're not specifying any nib name.

    • Where are you calling this?
    • What does the crash/debug log say? Does an exception get raised? Is it an EXC_BAD_ACCESS?
    • Is something wrong with the nib file?
    • What do you mean by "switch"? Are you "opening" the modal view controller or are you trying to swap an existing one?

    They're basically files that store (a part of) an app's UI (user interface, layout, connections between objects, etc.)

    I'm pretty sure the acronym stands for NeXT Interface Builder
  7. startrees

    startrees Member

    Joined:
    Nov 29, 2008
    Messages:
    223
    Likes Received:
    0
    Device:
    iPad 2 (White)
    I am calling it in an IBAction SwitchViews.
    It says EXC_BAD_ACCESS
    NO
    Opening
  8. iMicky

    iMicky New Member

    Joined:
    Dec 15, 2008
    Messages:
    968
    Likes Received:
    0
    Device:
    3G iPod touch
    I don't know ObjectiveC or code apps, but I thought they were replaced by the extension .xib?
  9. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    xib = flat, xml file; nib = "compiled" archive. two representations of the same thing, though xib seems to be preferred.
  10. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    • Is there anything "special" in your SecondViewController class you implemented?
    • Did you originally initialize the view controller like this?
    [OBJC]SecondViewController *screen = [[SecondViewController alloc] initWithNibName: @"SecondViewControllerOrWhateverMyNibNameIsButWithoutTheNibOrXibExtension" bundle: nil];
    /* ... */
    [/OBJC]

    On the device, in the final product, I'm pretty sure nibs are preferred, though. They're more compact and the binary plist format is much faster ("easier") to parse for the iDevice than XML.
    During development/before compilation, xibs are definitely preferred, though, because they're also human-editable to some extent (even though I know I would not want to edit them by hand...)
    Is that what you meant?

    BTW: Before Leopard, nibs weren't "compiled." There were only "editable" nibs and no xibs.

Share This Page