これが私のコードです。非常に単純ですが、エラーがわかりません
#import <Foundation/Foundation.h>
@interface Car: NSObject
@property(nonatomic,retain) NSString *brand;
@property int year;
@end //Car Interface
#import "Car.h"
@implementation Car
@synthesize brand, year;
@end //Car Implementation
#import "Car.h"
int main (int argc, const char * argv[])
{
int y;
//Creo un nuovo oggetto
Car *myCar = [[Car alloc] init];
//Setto i parametri
[myCar setBrand: @"BMW Z4"];
NSLog (@"Inserisci data modello: ");
scanf (" %i", &y); //E' buona norma lasciare uno spazio
[myCar setYear: y];
//Stampo a video i dati
NSLog(@"Marca: %@ Anno: %i", [myCar brand], [myCar year]);
return (0);
}
ここで私が得たエラー:
car.m:5:1: error: ivar 'brand' used by '@synthesize' declaration must be an existing iva
car.m:5:1: error: ivar 'year' used by '@synthesize' declaration must be an existing ivar
car.m:7:1: warning: incomplete implementation of class 'Car' [enabled by default]
car.m:7:1: warning: method definition for '-setBrand:' not found [enabled by default]
car.m:7:1: warning: method definition for '-brand' not found [enabled by default]
car.m:7:1: warning: method definition for '-setYear:' not found [enabled by default]
car.m:7:1: warning: method definition for '-year' not found [enabled by default]