New Project in Cocoa (Obj C)

Discussion in 'Mac Programming' started by MythicFrost, Jun 24, 2009.

  1. macrumors 68040


    Ok, I've just created my project in Cocoa (Obj C)..

    My app will be dealing with images, and other things etc... so I hope I picked the right project there's a lot of them.

    Does anyone know where to start?

    I see Main.m, is that where I add code? lol

    Kind Regards
  2. macrumors 68030


  3. macrumors 68040


    Thank you, I've read over some of the items, and I am reading a lot of tutorials atm from apple etc.. if anyone knows any really good ones please let me know.

    At the moment I am trying to add a button to my application in code... I'm not sure how, I tried seeing if 'Me' or 'This' access the main window or something but they don't.
    (I don't want to use IB, as the majority of the content on the window will be generated from code, and cannot be from the IB)
    I think I just need to add the button to the list of controls for the window, can anyone help me with this?

    My code:

    //  main.m
    //  TBNT
    //  Created by Icy on 17/06/09.
    //  Copyright __MyCompanyName__ 2009. All rights reserved.
    #import <Cocoa/Cocoa.h>
    int myFunction(int,int);
    int main(int argc, char *argv[])
    	NSString* myString = [NSString string];
    	myString = @"Hello";
    	NSNumber* myNumber = [NSNumber numberWithInt:(int)10];
    	myNumber = 0; //stop that stupid warning of not being used!
    	NSButton* myButton = [NSButton new];
    	[myButton setTitle:(NSString*)@"Test123"];
        return NSApplicationMain(argc,  (const char **) argv);
    int myFunction(int a, int b)
    	return a+b;
    Anyone know how to do this?

    Kind Regards
  4. macrumors 6502a


    You're not going to be able to teach yourself Cocoa using this approach...

    Get some books and make your way through them.
  5. macrumors 68040


    Yes, well I'm going to try anyway because I need to learn, and learn fast...
    Can you recommend any good books?

    Kind Regards
  6. macrumors 6502a


    It depends on your level of programming experience. If you're very comfortable with OOP, you can probably jump straight to Hillegass. If you're new to OOP languages, and/or programming in general, I would highly recommend that you begin with Kochan's book. Some here believe that you should start with regular C before moving up to Objective-C. I think both strategies have their merits, and the answer about what is best for you will depend heavily on how you learn best and what your programming goals are.
  7. macrumors 68040


    Thanks, I'll look into those, I have a lot of experience with Visual Basic, some with Visual C#, and a little with Visual C++, so I understand a lot of things.

    I'm in a very big hurry, so I'll learn obj-c and learn C later if necessary.

    Does anyone know where I find the event that runs when my application is first run?

    Is it main.m?

    I want to run a lot of code before you see the window (changing titles, adding content etc...)

    Kind Regards
  8. macrumors member


    all these questions (and a lot more) are answered by the book of Aaron.
    And if you want to learn things very fast, how about visiting a class of the BNR ( The classes are great and you learn a lot very fast!

    Best regards

Share This Page