views:

603

answers:

4

I'm getting this from an iPhone app I'm working on. Not sure how to interpret the error... It's thrown at a few place in my code. I can't see any pattern of occurrence.

Is this a generic error? What's the meaning of it?

+3  A: 

The error you posted indicates that you have a syntax error around your use of class. Manually inspect the first location the error is reported, and you might notice the cause.

To help you debug further, please include the surrounding code so we can better help you.

Most common causes:

  1. Missed @ in @class for forward class declaration in headers
  2. Missed ; after the declaration of an enum, a structure, or a typedef
  3. Copied C++ code, where class is used to declare a structure, but code is invalid in Objective-C
notnoop
Thanks for the pointers; I'm looking at it
Yav
A: 

Here's a snippet of the first error: expected '=', ',', ';', 'asm' or 'attribute' before 'class'

enter code here

import

import

import "User.h"

import "Location.h"

import "Media.h"

import "Logger.h"

@class Location; @class User; @class Media; @class Logger; @class DBHelper;

extern NSString *const XMLFinishedParsing; extern NSString *const XMLParsingFailed;

@interface ZFeedDelegate : NSObject { NSMutableArray *alteredItems; NSMutableArray *newItems; NSString *currentData; User *user; Media *media; Location *location; Logger *logger; }

@property (nonatomic, retain) Logger *logger; @property (nonatomic, retain) NSMutableArray *alteredItems; @property (nonatomic, retain) NSMutableArray *newItems; @property (nonatomic, retain) User *user; @property (nonatomic, retain) Media *media; @property (nonatomic, retain) Location *location; @property (nonatomic, retain) NSString *currentData;

  • (void)initCurrentData;
  • (void)releaseCurrentData;

@end

enter code here
Yav
A: 

I've just solved this exact same problem and I have been tearing my hair out over it.

GCC wasn't highlighting the problem in the header file where the error actually occurred - I had a stray 'B' character at the bottom of a header file (from running command-B to compile). The error was then being thrown in the .m file and other .h files which included the problematic one, often at the @class statement.

If it's throwing an issue with your @class statement, the problem is almost definitely in one of the preceding header files, as you include them directly beforehand - try commenting these out one-by-one and recompiling to find out which. Once you find the culprit file, finding the actual error will be much easier.

Rónán Ó Braonáin
A: 

Sorry to necro post, but Ronan is right on the money. I was doing some refactoring while making code changes during a Core Data versioning exercise and had an extraneous word at the top of one of my .h files. It was hard to catch but this thread gave me the warm lead I needed.

mcgski