У меня есть два свойства, которые я объявляю в своем заголовочном файле и синтезирую в своем файле класса (имя?):
- ширина
высота
(символ хеш / фунт) импорт
@interface Rectangle : NSObject { int width; int height; }
@property width, height;
-(int) area;
-(int) perimeter;
-(void) setWidth: (int) w setHeight: (int) h;
@end
.m файл:
(hash/pound symbol)import "Rectangle.h"
@implementation Rectangle
@synthesize width, height;
-(void) setWidth: (int) w setHeight: (int) h
{
width = w;
height = h;
}
-(int) area
{
return width * height;
}
-(int) perimeter
{
return (width + height) * 2;
}
@end
Однако я получаю некоторые ошибки:
error: syntax error before 'width;
error: no declaration of property 'width' found in the interface;
error: no declaration of property 'height' found in the interface;
Прошу прощения за форматирование У меня проблемы с символом # и форматированием кода.