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

lase

macrumors newbie
Original poster
Dec 24, 2008
7
0
I'm at wits ends trying to fix this. I've been googling for the last hour about this.

Any ideas?

The error is up in the @interface for Car...

Code:
#import <Foundation/Foundation.h>

//classes

@interface Car : NSObject
{
	-(NSString *) carModel;
	-(NSString *) ownerName;
	-int gasAmount;
}

-(void) setModel: (NSString *) m;
-(void) setOwner: (NSString *) o;
-(void) setGas: (int) g;

@end

@implementation Car
{
	-(void) setModel: (NSString *) m 
	{
		carModel = m;
	}
	-(void) setOwner: (NSString *) o
	{
		ownerName = o;
	}
	-(void) setGas: g
	{
		gasAmount = g;
	}
@end
		
		


int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

	Car *myCar = [[Car alloc] init];
	
	[myCar setModel:@"Ford F150"];
	[myCar setOwner:@"Anthony Crognale"];
	[myCar setGas: 1];
	
	NSLog([myCar carModel]);
	NSLog([myCar ownerName]);
	NSLog([myCar gasAmount]);
	
    // insert code here...
    [pool drain];
    return 0;
}
 

HiRez

macrumors 603
Jan 6, 2004
6,250
2,576
Western US
Don't put dashes or paretheses with your variable declarations. It should be like this:

Code:
@interface Car : NSObject {
    NSString *carModel;
    NSString *ownerName;
    int gasAmount;
}

The method declarations are fine.
 

HiRez

macrumors 603
Jan 6, 2004
6,250
2,576
Western US
Hmm, your method implementations need some work though. You need to write "(int) g" for setGas and in the other two where you are assigning objects you need to do some checks and retain/release if you're not using garbage collection. Also have a lot at the documentation for the @synthesize and @property keywords.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.