Cada vez que construyo el siguiente código, aparece el error anterior.error: especificador-calificador-lista esperado antes de ... en el objetivo C?
//Controller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"
#import "PolygonView.h";
@interface Controller : NSObject
{
IBOutlet UIButton *decreaseButton;
IBOutlet UIButton *increaseButton;
IBOutlet UILabel *numberOfSidesLabel;
IBOutlet PolygonShape *shape;
IBOutlet PolygonView *shapeView;
}
- (IBAction)decrease;
- (IBAction)increase;
- (void)awakeFromNib;
@end
//Controller.m
#import "Controller.h"
@implementation Controller
@end
Sin embargo, cuando reemplazo la instrucción de importación y pongo una referencia de referencia de clase en su lugar, el código se compila.
//Controller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"
@class PolygonView;
@interface Controller : NSObject
{
IBOutlet UIButton *decreaseButton;
IBOutlet UIButton *increaseButton;
IBOutlet UILabel *numberOfSidesLabel;
IBOutlet PolygonShape *shape;
IBOutlet PolygonView *shapeView;
}
- (IBAction)decrease;
- (IBAction)increase;
- (void)awakeFromNib;
@end
//Controller.m
#import "Controller.h"
#import "PolygonView.h"
@implementation Controller
@end
¿Alguien puede explicarlo?
PolygonShape y PolygonView probablemente tengan importaciones cíclicas. Es por eso que existen declaraciones avanzadas. Úselos, por favor. –
PolygonShape y PolygonView no tenían importaciones cíclicas, pero PolygonView y Controller sí. ¡Gracias por la ayuda! – Ridwan
@Jason: Eso probablemente sería una buena respuesta. – Chuck