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

Dev*_*any 1 macos xcode objective-c xcode4 xcode4.2

我点击了Modernize Project然后我得到了一些编译错误.(我拍了快照)

错误是:无法在@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;
Run Code Online (Sandbox Code Playgroud)

这是XCode中的错误

Eva*_*ski 11

您需要接口ivars的大括号:

@interface NSBezierPath (WBBezierPath)
{
  NSBezierPath        *flattenPath;
  NSPointArray        points;
  int                 numPoints;
}
Run Code Online (Sandbox Code Playgroud)

但是,由于您要定义类别,因此不允许使用ivars.您需要使用属性:

@interface NSBezierPath (WBBezierPath)

@property (nonatomic, strong) NSBezierPath *flattenPath;

/* Methods */

@end
Run Code Online (Sandbox Code Playgroud)