1

我点击了现代化项目,然后我得到了一些编译错误。(我确实拍了快照)

错误是:无法在@interface 或@protocol 中声明变量

这是复制和粘贴格式的代码。

#import <Cocoa/Cocoa.h>
#import "AJHBezierUtils.h"

@interface NSBezierPath (WBBezierPath) 

NSBezierPath        *flattenPath;

NSPointArray        points;

int                 numPoints;


+(NSBezierPath*)roundedPath:(NSRect)aRect radius2:(int)rad2;


-(NSPoint ) getLinePoints:(NSPoint )p1 p2:(NSPoint)p2  withDistance:(int )pointDistance;

- (NSPoint *)pointsFromPathWithDistance:(int)distance numberOfPoints:(int *)numberOfPoints;


- (float)distanceBetweenPoint:(NSPoint)a andPoint:(NSPoint)b;

- (int)numberOfPoints;

这是XCode中的错误

4

1 回答 1

11

接口 ivars 需要大括号:

@interface NSBezierPath (WBBezierPath)
{
  NSBezierPath        *flattenPath;
  NSPointArray        points;
  int                 numPoints;
}

但是,因为您要定义一个类别,所以不允许使用 ivars。您需要改用属性:

@interface NSBezierPath (WBBezierPath)

@property (nonatomic, strong) NSBezierPath *flattenPath;

/* Methods */

@end
于 2012-06-13T21:55:28.787 回答