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

cybrscot

macrumors 6502
Original poster
Dec 7, 2010
282
0
Somewhere in Southeast Asia
Hey team,
I decided to do a simple Xcode project from another book, just to keep it interesting and get familiar with Xcode. A couple things, the book doesn't specify which version of Xcode it's using, but the book was printed in 2009 and I downloaded Xcode in December of 2010. The only difference I've seen so far is in the Library Window. The book says the Library window has two tabs: Objects and Media. The book also shows pictures of the Xcode windows, and I see that the Library window picture shows it with only those two tabs. However my LIbrary window has 3 tabs. I have Objects/Classes/Media. So maybe they just moved things around in an Xcode update?

I'm following along with a simple calculator project in the book, everything is done and looks perfect, but when I "build and run" in Xcode, I'm getting an error in the code. I've included the code from my Xcode project. It's exactly as the book shows. I don't see any spelling errors either ! :D

My copy and past didn't carry over the errors from my build, so I inserted them as comments. It said that two items were undeclared. Obviously the first thing I did was just add them to the int and declare them. But then it said that they were not used. :confused::confused:

I added them to the int declaration, even though they didn't do that in the book, only because that was the error that was returned by the Xcode compiler. Take a look please. Thanks


Code:
//
//  Fusebox.m
//  MyfirstApp
//
//  Created by Scott Dean on 2/9/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Fusebox.h"


@implementation Fusebox

- (IBAction)calculateAnswer: (id)sender
{
	int num1, num2, answer; 
	num1 = [numberField1 intValue];             //!numberField1 undeclared
	num2 = [numberField2 intValue];             //!numberField2 undeclared
	answer = num1 + num2;
	
	[answerField setIntValue:answer];
}	

@end
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.