Programming Objective-C in XCode 4 – iPhone iOS 4.3 Hello, World! tutorial

You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “Programming Objective-C in XCode 4 – iPhone iOS 4.3 Hello, World! tutorial”.

Posted in Apple, Development, Objective-c, Okategoriserade, OSX, XCode Tagged with: , , , , , , , , , , ,
177 comments on “Programming Objective-C in XCode 4 – iPhone iOS 4.3 Hello, World! tutorial
  1. Paul Peelen says:

    This is because you are using the new ARC (Automatic Refference Counting). Using ARC it is not needed to allocate and release objects.
    So, remove all the release, dealloc and retain reffences and methods and you should be fine.


  2. Paul Peelen says:

    @DanielW: My guess is that you made a spelling misstake. What you can do is check what the file name is called. The header file (.h which you are reffering to) should be the same as the one between ” and “.

    Regarding your code questions: I have tried to make the tutorial as general as possible yet still according to my writing style. Every developer has his/her own style of coding, hence you as well 😉 My apps are written this way… and I have about 13 or so available on the iTunes AppStore.

  3. Paul Peelen says:

    Yes, you are right. I will write a new one as soon as I get the time… for iOS 5.0.1> and Xcode 4.3+

  4. Antonia Seegers says:

    Really like your layout. Some uselful content too 😉

  5. sangram says:

    thanks a lot……………….

  6. Dan says:

    Didn’t quite match what I see in XCode 4.2, but helpful nonetheless.

  7. Billy Kimble says:

    Thanks for this tutorial. It helped me get up to speed on the latest version of XCode after taking a year off from playing around with Xocde 3 🙂

  8. ramdak says:

    I’m frustrated… I can’t make it work. I’m using Xcode 4.3.2, targeting iOS4.3 and I get this error and the app don’t launch and it compiles OK…

    2012-03-30 16:51:24.118 boton simple[377:b903] *** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key textoLBL.’
    *** Call stack at first throw:
    0 CoreFoundation 0x00fd55a9 __exceptionPreprocess + 185
    1 libobjc.A.dylib 0x01129313 objc_exception_throw + 44
    2 CoreFoundation 0x00fd54e1 -[NSException raise] + 17
    3 Foundation 0x00794677 _NSSetUsingKeyValueSetter + 135
    4 Foundation 0x007945e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
    5 UIKit 0x0021030c -[UIRuntimeOutletConnection connect] + 112
    6 CoreFoundation 0x00f4b8cf -[NSArray makeObjectsPerformSelector:] + 239
    7 UIKit 0x0020ed23 -[UINib instantiateWithOwner:options:] + 1041
    8 UIKit 0x00210ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
    9 UIKit 0x0001617a -[UIApplication _loadMainNibFile] + 172
    10 UIKit 0x00016cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
    11 UIKit 0x00021617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12 UIKit 0x00019abf -[UIApplication sendEvent:] + 71
    13 UIKit 0x0001ef2e _UIApplicationHandleEvent + 7576
    14 GraphicsServices 0x00cd6992 PurpleEventCallback + 1550
    15 CoreFoundation 0x00fb6944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    16 CoreFoundation 0x00f16cf7 __CFRunLoopDoSource1 + 215
    17 CoreFoundation 0x00f13f83 __CFRunLoopRun + 979
    18 CoreFoundation 0x00f13840 CFRunLoopRunSpecific + 208
    19 CoreFoundation 0x00f13761 CFRunLoopRunInMode + 97
    20 UIKit 0x000167d2 -[UIApplication _run] + 623
    21 UIKit 0x00022c93 UIApplicationMain + 1160
    22 boton simple 0x00002615 main + 181
    23 boton simple 0x00001ea5 start + 53
    terminate called throwing an exception(lldb)

  9. Paul Peelen says:

    It can mean numerous things when not having the code… but usually the error “this class is not key value coding-compliant for the key …” occurs when your IBOutlet references to something that doesn’t exist. So check you nibs.
    Otherwise, send me the code at paul at paul peelen dot com.

  10. Salinda says:

    Nice concise but informative one, Thank you very much!

  11. Armando says:

    Thanks for the tutorial it works fine for iPad with IOS 5.0 just one question, in teh simulator after I press the button and the label change, if I close the application in the simulator and I try to open it again in the icon the app crash, I think is because something of the memory stored. what can be done in this case. I’m just starting in the iPad development and as you I was a PHP developer after I move to oracle and now I want to learn Objective C.

    thanks in advance.

  12. Pete says:

    Thanks Paul for making this tutorial. The transition to XCode 4.3 is definitely not easy, and for C++ programmer, objective-C remains bloody confusing to me! I wish Apple adopted C++.

  13. Kev says:

    Excellent, Paul! Was easy to follow, even for a newb like me. Had to then read the comments about getting around the ARC business – which got it all working. Thanks again.

  14. Paul Peelen says:

    @Armando: There can be many reasons. By default, the simulators app should not crash when returning. What does the log say?

    @Pete & @Kev: Thnx! =)

  15. @wlonline says:

    Did the same tute a slightly different way today. Yours was clear and I got it to work ok, no probs.

  16. Danny says:

    The spelling is horrendous, I could be barely make out what you’re trying to say in a few points (yes I speak English as a Native, first language speaker). You didn’t explain what nonatomic and retain actually do. Also, where is the code that shows the linking between the buttons and the text. Yes, you make the links with File Owner but where is that shown to the compiler? Can you change that? Compared to regular C and C++ tutorials, this didn’t help me one bit. Its easy to copy and paste code, but to know what each line is doing, and how it fits in into the source and make files means you can go to the next level. Very Disappointed.

  17. Paul Peelen says:

    Well, I guess there is a little Sheldon in all of us. Apparently you are one of the few having problems with my spelling, too bad. However, if you have so much problems with my spelling, why did you continue reading the article?
    In objective-C you do not both use GUI tools and programatically connect GUI components to the code. Either you are using IB to connect you GUI to your code, or you do it all in the code itself. If you are looking for a C or C++ way of doing Objective-C,… I recommend you look into cross-compiling. Otherwise… just suck it up and learn how to do it the right way.

    Good luck!

  18. Totara says:

    Many thanks !

  19. Cathi says:

    Hai, I’m totally new to this Objective – C. As I din’t do any projects in my college. I don’t have a clear picture as how to learn this new lang. Can you suggest some ideas. Thank u in advance.

  20. will says:

    Quick question(s), why do my iOS templates appear in black and white? and why do i not have the view-based application template? Please help

  21. Paul Peelen says:

    @Will: I am unsure what you mean.. could you please elaborate?

  22. GouthamP says:

    One Quick Question, at the start when you started coding, your Project Navigator shows files as “helloWoldViewController.h” mine still shows only as “ViewCollector.h” what am I doing wrong?

  23. Paul Peelen says:

    Hard to say, It might be because XCode has been updated quite a lot since I wrote the tutorial.

  24. Dan says:

    Good tutorial. Some missing dots, but I was able to connect them given time. I hope you’ll write more like this.

  25. Hitesh Kumar Singh says:

    hi, very nice and simple tutorial… keep posting article like this… it’s been just 2 days to my iphone development career and i was able to build my first app with the help of your article. many many thanks 🙂

  26. Parks Daniel says:

    Well-written article you shared here. Information which you wrote in this post, its very easy to understand and helpful. Share another informative post like this. Thank you.

  27. chameleon says:

    Thank You
    Nice Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *