Apple 's tutorial not working, worth it to follow anyway?

Discussion in 'Mac Programming' started by Ja Di ksw, Sep 19, 2013.

  1. Ja Di ksw, Sep 19, 2013
    Last edited by a moderator: Sep 25, 2013

    macrumors 65816

    Ja Di ksw

    Apr 9, 2003
    Hi everyone. Apple give a tutorial for learning how to make some apps, but it doesn't seem to work with the latest version of Xcode, which is giving me errors even running a blank app! I'll explain:

    I'm pretty much brand new at programming (I wrote a bunch of stuff in NetLogo a few years ago, and a *tiny* bit in Matlab way before that, but yeah, very very new). I want to learn Objective-C for what an app that won't be crazy complex, but also won't be the simplest thing in the world. To help, I've been reading Kochan's book on Objective-C programming.

    Anyways, I went to Apple's tutorial ( and started to do it simultaneously with Kochan's book.

    Right off the bat, the tutorial tells you to create a new app and just hit run with it blank. Then it starts with simple sliders / text box / button connections. So, I had no problem doing the work on the sliders and whatnot, but hitting run (even before doing ANYTHING) returns a list of 11 errors. Everything is in Frameworks/Other Frameworks/AppKit.framework. For example, in Frameworks/Other Frameworks/AppKit.framework/Headers/NSCell.h there are two lines that both give the error "Expected a type". The lines are:

    - (NSUserInterfaceLayoutDirection)userInterfaceLayoutDirection NS_AVAILABLE_MAC(10_6);
    - (void)setUserInterfaceLayoutDirection:(NSUserInterfaceLayoutDirection)layoutDirection NS_AVAILABLE_MAC(10_6);
    So, is it even worth it to try with Apple's tutorial? I'm not sure why things are failing to run even before I enter any code, but I'm not sure how I'm going to get past problems located in the AppKit with my level of experience.

    Thanks for any feedback!
  2. macrumors 68000

    Mar 29, 2009
    I'm guessing the error is in how you created the app, or configuration of Xcode or something.
  3. macrumors 6502a

    Dec 2, 2008
    Start at the beginning

    I can't quite tell what's going on with your setup, but the template applications provided in Xcode will run. First time. Right out of the box.

    If one of those templates doesn't run, you need to get that figured out before doing anything else. My suggestions:

    1. Restart your computer.
    2. Download Xcode from the Mac Apple Store.
    3. Start Xcode. Select Create New Xcode Project. Select OS X / Application / Cocoa Application. Enter:
    product name: test01
    organization name: robvas
    company identifier:
    class prefix: RBV
    app store category: none
    create document based application: (unchecked)
    use core data: (unchecked)
    select: OK
    create git repository: (checked)
    select: create​

    Press the play button. The application will run.

    You MUST do each step above exactly. Exactly means exactly.

    If you do the above and it doesn't work, post EXACTLY what you did. If you are dead sure that you don't need Xcode from MAS and you used a copy of Xcode you got from some friend at uni, tell us. If you're not using a Mac but some kind of hackintosh, tell us. If you're running 10.3.3 because of whatever, tell us.
  4. thread starter macrumors 65816

    Ja Di ksw

    Apr 9, 2003
    Thanks for the in-depth help, that got it working.

    I'm somewhat curious about why though... The product name and organization were different, but that shouldn't matter. Everything else I had the same except the company identifier and class prefix which were different, but I just made another test with a non-"com.etc" identifier and no class prefix and it worked...

    Anyways, no idea how that fixed it, would be interested to know but glad it did work in any case. Thank you!
  5. macrumors 6502a

    Dec 2, 2008
    I forgot to mention . . .

    I forgot to mention that Xcode can read your mind - it's looking for negative thoughts. So if you're in a bad mood or don't like the new iPhone 5s or your spouse just left you, Xcode will add spurious errors to your code.:)
  6. thread starter macrumors 65816

    Ja Di ksw

    Apr 9, 2003
    That makes perfect sense! Happy with my brand new wife (3 weeks today!), but definitely in a "wtf is up with trying to learn Objective-C!" mood.....
  7. macrumors member

    Jul 20, 2011
    i can tell you right off the bat, if you plan on learning "objective-c" and sticking with it for any time other than a single one off program...with out a doubt learn about c first. i will explain in a somewhat lengthy but understandable reason.

    "objective-c" and "apple frameworks" are not one and the same. it's like calling a loaf of bread and some meat, a sandwich. objective-c is like a dictionary, but apple's "cocoa" & "cocoa touch" frameworks are like the grammer that puts it all together to make a sentance or a novel. on top of that, some apple frameworks are objective-c based, but the reality is most of the important ones are all c based. ones like core animation (making pretty transitions and things move) & core graphics (making pretty drawings and images). objective-c in itself is not that hard to pick up, and it's a relatively eligant language. however it is a strict superset of c. what this means is unlike other languages like c#, pure c code and objective-c code can innermingle with each other and does so very often. with out understanding the different primative types and the components of c, some parts of the apple frameworks are not going to make sense and you will end up just copy and pasting code you googled and will have no clue what it means or how it works. the bottom line is objective-c is just c under the hood. all the high level apple api is just making c function calls for you at a lower level. what ever book you plan on getting or using, do yourself a favor and don't gloss over the c section. it will pay you back 10 fold in the future i can assure you. also, get a couple books. not every author's writing style clicks with every reader. having multiple explinations of the same topic can never hurt and will only help solidify your understanding. this applies to the c level and the objective-c level.
  8. macrumors 6502

    Aug 21, 2013
    San Francisco
    I agree with this 100%. When I first started programming, I jumped right into Objective-C without really knowing anything about C. I had some mentors tell me to take the extra time and learn C first instead, which I did, and it has proven to pay off, like you said.

Share This Page