2012-06-13 30 views
1

我單擊了Modernize Project,然後出現了一些編譯錯誤。 (我沒有拍攝快照)錯誤:無法在@interface或@protocol中聲明變量

的錯誤是:無法聲明中@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; 

Here is the error in XCode

回答

11

您需要大括號接口的ivars:

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

但是,因爲要定義一個類,實例變量是不允許的。您需要改用屬性:

@interface NSBezierPath (WBBezierPath) 

@property (nonatomic, strong) NSBezierPath *flattenPath; 

/* Methods */ 

@end 
+1

究竟是什麼,我只是打字,你打我吧;)的快速反應 –

+0

謝謝你們!我做到了這一點......但是,這產生了更多的錯誤....會張貼截圖。 http://screencast.com/t/B1pfn3yPlKor – DevCompany

+1

在您的新屏幕截圖中,您放置了大括號(「}」)而不是開放大括號(「{」)。如果你沒有隱藏第一個錯誤標籤,我相信它確切地告訴你。 – abarnert

相關問題