DevCompany
DevCompany

Reputation: 699

ERROR: Cannot declare variable inside @interface or @protocol

I clicked Modernize Project and then I got some compile errors. (I Did take a snapshot)

The error is: Cannot declare variable inside @interface or @protocol

Here is the code in copy and paste format.

#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

Upvotes: 1

Views: 5296

Answers (1)

Evan Mulawski
Evan Mulawski

Reputation: 55354

You need braces for interface ivars:

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

However, because you are defining a category, ivars are not allowed. You need to use properties instead:

@interface NSBezierPath (WBBezierPath)

@property (nonatomic, strong) NSBezierPath *flattenPath;

/* Methods */

@end

Upvotes: 11

Related Questions