Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,940
38
Australia
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
 

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,940
38
Australia
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:

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
 

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,940
38
Australia
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

macrumors 6502a
Oct 26, 2003
932
8
Richmond, VA
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

macrumors 68040
Original poster
Mar 11, 2009
3,940
38
Australia
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

macrumors member
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.