Wow, I feel dumb

Discussion in 'iOS Programming' started by RonC, Nov 3, 2011.

  1. RonC, Nov 3, 2011
    Last edited: Nov 3, 2011

    RonC macrumors regular

    Joined:
    Oct 18, 2007
    Location:
    Chicago-area
    #1
    I downloaded Xcode 4.2 recently and created a new project. I've built stuff using previous versions of Xcode without too much difficulty, but I'm completely lost and need a little guidance.

    I want a little app that has a single view, with a couple of buttons and labels and regular old UI stuff. I knew how to put this together until Xcode 4.2.

    First, I didn't recognize any of the templates. Is there a good template for a TableView app?

    Because I didn't recognize any of the templates, I chose the "Single View Application" template.
    Second, WTF is a Storyboard and why would I want to use that? I want my .xibs, dammit.

    I managed to convince it to create a .xib by unchecking the storyboard box. I also turned off ARC, because I don't understand that either.​

    Finally, this project, straight out of the box, doesn't actually run! Here's what I get:
    Code:
    2011-11-03 18:42:09.998 eMoocher[15560:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x4b1a9f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
    *** Call stack at first throw:
    (
    	0   CoreFoundation                      0x00fb8be9 __exceptionPreprocess + 185
    	1   libobjc.A.dylib                     0x0110d5c2 objc_exception_throw + 47
    	2   CoreFoundation                      0x00fb8b21 -[NSException raise] + 17
    	3   Foundation                          0x007796cf _NSSetUsingKeyValueSetter + 135
    	4   Foundation                          0x0077963d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    	5   UIKit                               0x002098d6 -[UIRuntimeOutletConnection connect] + 112
    	6   CoreFoundation                      0x00f2f2cf -[NSArray makeObjectsPerformSelector:] + 239
    	7   UIKit                               0x002082ed -[UINib instantiateWithOwner:options:] + 1041
    	8   UIKit                               0x0020a081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    	9   UIKit                               0x00014943 -[UIApplication _loadMainNibFile] + 172
    	10  UIKit                               0x000154ca -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
    	11  UIKit                               0x0001fdb2 -[UIApplication handleEvent:withNewEvent:] + 1533
    	12  UIKit                               0x00018202 -[UIApplication sendEvent:] + 71
    	13  UIKit                               0x0001d732 _UIApplicationHandleEvent + 7576
    	14  GraphicsServices                    0x00cbca36 PurpleEventCallback + 1550
    	15  CoreFoundation                      0x00f9a064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    	16  CoreFoundation                      0x00efa6f7 __CFRunLoopDoSource1 + 215
    	17  CoreFoundation                      0x00ef7983 __CFRunLoopRun + 979
    	18  CoreFoundation                      0x00ef7240 CFRunLoopRunSpecific + 208
    	19  CoreFoundation                      0x00ef7161 CFRunLoopRunInMode + 97
    	20  UIKit                               0x00014fa8 -[UIApplication _run] + 636
    	21  UIKit                               0x0002142e UIApplicationMain + 1160
    	22  eMoocher                            0x00001d7d main + 125
    	23  eMoocher                            0x00001cf5 start + 53
    )
    
    That points back to this code, in main.m:

    Code:
    int main(int argc, char *argv[])
    {
        @autoreleasepool {
            return UIApplicationMain(argc, argv, nil, NSStringFromClass([EMAppDelegate class]));
        }
    }
    
    specifically, that return line.

    So here I am, completely unable to even get started. Please help, at least to get me past this part.
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    Well, I'm having a bit of trouble and being a bit pissed about this as well, for 'once again', ruining what we already have.
    What I did, is create an empty XIB (there is an option for Application Delegate at new File, User interface). Then at my Target, tell it, it has to use the MainWindow, and build from scratch there, add a view controller, or a plain view. Or whatever.
    What you are trying to do from your crash log, it's trying to use a IBOutlet which it doesn't have.
     
  3. RonC thread starter macrumors regular

    Joined:
    Oct 18, 2007
    Location:
    Chicago-area
    #3
    Yeah, I figured that was what it was, but doesn't UIViewController have the "view" outlet? InterfaceBuilder seems to think it does...

    I'll give your way a go -- what the heck, it doesn't work now, so how much worse can it get...

    Thanks for the help.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    New Features in Xcode 4.2.

    It might help to know which version of Xcode you're coming from.

    Also, have you read anything regarding Xcode 4.2? I take it you didn't read the What's New in 4.2 document, or you wouldn't have asked what Storyboards are. So if you didn't read anything at all, not even release notes, then starting there might be good. For example, look under Xcode's Help menu.
     
  5. RonC thread starter macrumors regular

    Joined:
    Oct 18, 2007
    Location:
    Chicago-area
    #5
    Thanks for the pointer. Looks like I have some reading to do.

    I was able to get it to go, so I'm at least able to do something until I finish reading.
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    It's now called "Master-Detail".
     
  7. CheesePuff macrumors 6502

    Joined:
    Sep 3, 2008
    Location:
    Southwest Florida, USA
    #7
    You said you are not using ARC but the code you show from main.m shows that you are.
     
  8. ppilone macrumors 6502

    Joined:
    Jan 20, 2008
    #8
    I'd read up on Storyboard's before yelling WTF. They provide some really nice features and allow you to perform segues easily, reducing the amount of redundant code in your app.

    Also, you can still use xibs even if you application uses storyboards. It's common to use storyboards for the main flow of your app and xibs when it's more convenient.
     
  9. RonC thread starter macrumors regular

    Joined:
    Oct 18, 2007
    Location:
    Chicago-area
    #9
    I meant to turn it off, and I thought I did (by not checking the box that said "Use Automatic Reference Counting"); it's certainly possible that I checked it in error.

    I'm still feeling my way around the new Xcode. I did a lot of work in Xcode 4.1.2 (? - the immediate prior version) and actually managed to ship an app or two - all internal enterprise or ad hoc distribution.

    I was quite surprised by the changes in Xcode 4.2, so my reaction may be stronger than others who knowingly jumped in. I'll get it, I'm sure.

    I do appreciate the helpful comments here, though.
     
  10. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #10
    Custom segue's kick ass. Storyboarding is odd at first but once you get the hang of it, you will come to love it more than individual nibs.
     
  11. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #11
    @autoreleasepool works with and without ARC turned on.
     
  12. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #12
    When I try to build with Storyboards for pre iOS 5.x it doesn't build, so i'm all for individual nibs, sorry ;o
     
  13. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #13

    It should work for 4.3 and greater.
     
  14. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #14
    Yeah, but I'd like to support iOS 4.0-4.1-4.2 too..
    And if I try to build on an iPhone with iOS 4.3.5, it gives me a warning it doesn't support Storyboard, so that's rather strange..
     
  15. MythicFrost macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #15
    Storyboard supports iOS 5 only, from what I've read. I'd try starting a new project. (ARC might also require iOS 5.)

    ARC means you don't have to worry about garbage collection IIRC.
     
  16. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #16
    Exactly, i just tried to run on an iOS 4.3.5 device, Storyboard didn't work out..
    Seriously am NOT liking this.
     
  17. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #17
    I do believe Arc is also supported with 4.3 and up. You will need to add the required values to your plist for storyboard support.
     
  18. MythicFrost macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #18
    Ah, okay. Wasn't sure about that one.
     

Share This Page