Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Newby trying to learn Obj-C in XCode...

Newby trying to learn Obj-C in XCode...
Thread Tools
Fresh-Faced Recruit
Join Date: May 2005
Location: Sydney, Australia
Status: Offline
Reply With Quote
Apr 26, 2009, 09:14 AM
 
Hello... OK so last time I programmed for real was in C on Unix terminals in 1992... Now I'm trying to get into iPhone dev, and that involves...
- XCode environment
- Objective C

Both of which are hurting my brain.

I've decided to learn Objective-C and OO programming in general first, then move onto the frameworks and whatnot of the iPhone.

So I headed to the Objective-C Beginner's Guide at http://www.otierney.net/objective-c.html which is a nice intro, but I can't even get the first Classes example working (the Fractions class) :-(

I have a main.m, Fraction.h, and Fraction.m and I've scoured for syntax errors but in XCode it won't run.... instead i get these errors in the build results:
".objc_class_name_NSObject", referenced from:
.objc_class_name_Fraction in Fraction.o
"_objc_msgSend", referenced from:
_main in main.o
_main in main.o
_main in main.o
_main in main.o
_main in main.o
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I'm really really really new at this and obviously struggling with the very basics so have no idea where I'm going wrong.

I don't even know if I created the correct type of project in XCode, or the right type of file.

Can anyone please help point me in the right direction?
I want something good to die for, to make it beautiful to live.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Apr 26, 2009, 02:14 PM
 
It sounds like you're not including Cocoa in the project. Did you make a Cocoa Application project (or a Cocoa Document-Based Application, or something else with "Cocoa" in the name)?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Apr 26, 2009, 02:17 PM
 
Sounds like you didn't link against the Foundation framework. Go to Project -> Add To Project... and then add /System/Library/Frameworks/Foundation.framework to the project. Then, your app should compile.

In the future, if you want to use Objective-C, you should start with Xcode's "Foundation Tool" template if you're making a command-line tool, or "Cocoa Application" or "Cocoa Document-based Application" if you're making a full-blown GUI app.

edit: beaten by the other Charles. However, since the only thing missing is NSObject, I'd guess he's trying to make a Foundation tool, and thus including just Foundation should work (but adding the entire Cocoa framework would work too).

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
Fresh-Faced Recruit
Join Date: May 2005
Location: Sydney, Australia
Status: Offline
Reply With Quote
Apr 26, 2009, 05:13 PM
 
Chuckit and CharlesS... You were both right...

I had created a new project based on the C++ Tool Template (d'Oh!), as the Objective-C Beginner's Guide didn't specify what to do here (it's IDE-neutral), so I took a stab at what I thought may be right LOL!

Thanks very much guys - adding the Foundation.framework fixed the problem.

I knew it would be simple for you fellas ;-)
I want something good to die for, to make it beautiful to live.
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Apr 26, 2009, 05:42 PM
 
BTW, if you want something that's more specifically tailored to Mac OS X, this book is supposed to be really good for learning Cocoa programming. I haven't read it myself, but I've often seen it heartily recommended by those who have.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
Fresh-Faced Recruit
Join Date: May 2005
Location: Sydney, Australia
Status: Offline
Reply With Quote
Apr 27, 2009, 04:46 AM
 
Thanks for the advice... I already own that book and it's too advanced for my level ;-)

I'll get there eventually...
I want something good to die for, to make it beautiful to live.
     
Dedicated MacNNer
Join Date: Jul 2002
Status: Offline
Reply With Quote
Apr 27, 2009, 11:47 AM
 
A friend of mine from Stanford pointed me to a series of great podcasts on iTunes-U provided for free by Stanford university. Search iTunes for "stanford cs-193p." It's an introductory course to development on the iPhone -- ObjC and Interface Builder. It assumes you have a basic understanding of OOP, like one semester of Java programming or something.

It's been really helpful to me, as I just started digging into ObjC last week.

-Rob
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2