PDA

View Full Version : New Project in Cocoa (Obj C)




MythicFrost
Jun 24, 2009, 07:50 PM
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



Catfish_Man
Jun 24, 2009, 07:56 PM
Note the guides listed at the top of this forum... http://guides.macrumors.com/Category:Developer

MythicFrost
Jun 24, 2009, 11:17 PM
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

GorillaPaws
Jun 24, 2009, 11:28 PM
You're not going to be able to teach yourself Cocoa using this approach...

Get some books and make your way through them.

MythicFrost
Jun 24, 2009, 11:31 PM
Yes, well I'm going to try anyway because I need to learn, and learn fast...
Can you recommend any good books?

Kind Regards

GorillaPaws
Jun 24, 2009, 11:59 PM
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.

MythicFrost
Jun 25, 2009, 12:44 AM
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

pstoehr
Jun 25, 2009, 01:55 AM
Hi,


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
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 (http://www.bignerdranch.com). The classes are great and you learn a lot very fast!

Best regards
Peter