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

JDoggG4

macrumors newbie
Original poster
Aug 25, 2007
4
0
Hey guys I'm trying to make a cocoa application that has a GUI that shows a drop down menu and a button called "Launch", the user chooses a game from the list and clicks "Launch", once they do that the application launches ([[NSWorkspace sharedWorkspace] launchApplication;, or something like that) I just started cocoa programming and really hope you can help me with this problem I'm having.


main.m
Code:
//
//  main.m
//  XG-Emulator
//
//  Created by JDogg on 22/12/07.
//  Copyright __MyCompanyName__ 2007. All rights reserved.
//

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
	NSString *chosenGame = [dropDown selectedItem];
[[NSWorkspace sharedWorkspace] launchApplication:chosenGame];
}
untitled.h
Code:
#import <Cocoa/Cocoa.h>
@interface dropDown : NSObject
{
	NSString *chosenGame = [dropDown selectedItem];
	[[NSWorkspace sharedWorkspace] launchApplication:chosenGame];
	
}
@end
I get the error "dropDown undeclared (first use in this function)
Download the XCODE (3.0) Project:http://deathlyinvasionclan.com/jmacsoft/files/XG-Emulator.zip
 

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
You're doing it completely and totally wrong. Get Programming in Objective-C by Stephen Kochan and read it.

(I'm not trying to be rude, but really you're so far off that by the looks of it one would have to give you a complete introduction to Object Oriented programming and the Objective-C language. That's too much to ask in a forum thread. Getting a book on the subject will be a much better way to go.)
 

JDoggG4

macrumors newbie
Original poster
Aug 25, 2007
4
0
You're doing it completely and totally wrong. Get Programming in Objective-C by Stephen Kochan and read it.

(I'm not trying to be rude, but really you're so far off that by the looks of it one would have to give you a complete introduction to Object Oriented programming and the Objective-C language. That's too much to ask in a forum thread. Getting a book on the subject will be a much better way to go.)
I'm currently reading COCOA PROGRAMMING FOR MAC OS X SECOND EDITION By Aaron Hillegass. And you are right, I should read more, but all I want to know is how I can get the program to work
 

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
Well what I'm trying to say is that it's not a short answer or a matter of tweaking what you're already got. You need to start over because what you've got is not even the beginnings of a working application. The main() function you've got should have remained unchanged from the template. What you have in there shouldn't be in there at all. The second file is a header. Headers are supposed to contain declarations only, no definitions. You've got actual code in there. Really it's difficult to explain. It's like if someone posted asking for help getting their car to start and asking if you could you just explain the minor mistake they'd made. You come in expecting to tell them to make sure they hold down the brake before shifting into drive, but instead they've posted a picture of a dead elephant with a wheel glued to its head and an exhaust pipe for a tail and you just really can't even begin to explain the problem...because they so obviously don't know where to start.

The book you've got is an excellent one, but I would suggest going through the book I mentioned earlier. Before you can effectively learn Cocoa (the APIs) you need to know Objective-C (the language) and it's pretty clear that you don't yet have a good grasp of the language yet.

Again, I'm really trying to help, but you need a more than a little help, you've got a lot to learn first. Programming is not simple or easy, but it is very much worth learning, so keep at it.
 

JDoggG4

macrumors newbie
Original poster
Aug 25, 2007
4
0
Well what I'm trying to say is that it's not a short answer or a matter of tweaking what you're already got. You need to start over because what you've got is not even the beginnings of a working application. The main() function you've got should have remained unchanged from the template. What you have in there shouldn't be in there at all. The second file is a header. Headers are supposed to contain declarations only, no definitions. You've got actual code in there. Really it's difficult to explain. It's like if someone posted asking for help getting their car to start and asking if you could you just explain the minor mistake they'd made. You come in expecting to tell them to make sure they hold down the brake before shifting into drive, but instead they've posted a picture of a dead elephant with a wheel glued to its head and an exhaust pipe for a tail and you just really can't even begin to explain the problem...because they so obviously don't know where to start.

The book you've got is an excellent one, but I would suggest going through the book I mentioned earlier. Before you can effectively learn Cocoa (the APIs) you need to know Objective-C (the language) and it's pretty clear that you don't yet have a good grasp of the language yet.

Again, I'm really trying to help, but you need a more than a little help, you've got a lot to learn first. Programming is not simple or easy, but it is very much worth learning, so keep at it.
Thank you very much for your pointers and advice. I agree it would be easier to learn objective C before getting into Cocoa, so I am going to buy the book you recommended and hopefully I learn something from it. I have no programming background besides HTML, applescript and a little tiny bit of Java
 

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
Thank you very much for your pointers and advice. I agree it would be easier to learn objective C before getting into Cocoa, so I am going to buy the book you recommended and hopefully I learn something from it. I have no programming background besides HTML, applescript and a little tiny bit of Java

That's a good way to go and you'll be glad you did. For what it's worth, I've read a lot of technical books (I have a degree in electrical engineering and do that for a living) and Kochan's book is one of the best I've ever read. If you go through it and do all the exercises you'll come out the other end quite comfortable with ObjC and Hillegass's book will be much easier to get through and understand. Don't hesitate to ask questions here if there's something you don't understand, but do make sure you've done your homework first.
 

tjwett

macrumors 68000
May 6, 2002
1,880
0
Brooklyn, NYC
...It's like if someone posted asking for help getting their car to start and asking if you could you just explain the minor mistake they'd made. You come in expecting to tell them to make sure they hold down the brake before shifting into drive, but instead they've posted a picture of a dead elephant with a wheel glued to its head and an exhaust pipe for a tail and you just really can't even begin to explain the problem...because they so obviously don't know where to start.

i'd like to just say that is the funniest damn thing i've ever read on these forums, and i've been around a while. i think i just LOL'd in my pants.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.