2

Hi trying the compile Objective C++/Protocol code but the compilation fails with error “Expected declaration specifier before protocol” and similar error for all the objective c line of code in the following header.

#import <UIKit/UIKit.h>

#include <Category>

@protocol StoreDelegate <NSObject>
@optional
...//Protocol methods
...
...

@end

@interface Store : NSObject {
    id<StoreDelegate> delegate;
    BOOL downloadFailed;
    Category *currentCategory;
}

@property(nonatomic, assign) id<StoreDelegate> delegate;

+ (Store *)sharedStore;
...//Class methods
...
...
@end

Note that “Category” is a C++ class. If I remove the protocol related code from the class then the code compiles fine. Is there a way to restructure the above code and get it compile?

1 Answer 1

2

You are probably including that header in a pure C++ source file. Make sure that any files that include that header are compiled as Objective-C++ either by changing the extension to .mm or by changing the file type to sourcecode.cpp.objcpp in the genral tab of the info window.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.