Voici mon code. Il est très simple, mais je ne comprends pas l'erreurErreur lors de la compilation du code objectif-c
#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);
}
Voici les erreurs que j'ai obtenu:
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]
C'est presque le même code que dans votre question précédente http://stackoverflow.com/questions/17996426/any-mistakes-using-property-and-synthesize. Pourquoi acceptez-vous la réponse si cela ne fonctionne pas pour vous? - Et peut-être devriez-vous encore mentionner que vous utilisez ** GNUstep **. –
Oui, c'est le même code mais j'ai résolu le problème précédent en fait j'ai plus cette erreur. Maintenant, le problème est différent. – Mazzy
Il ne s'agit pas de GNUstep. J'utilise clang avec GNUstep et je peux compiler votre code très bien. –