【发布时间】:2011-04-28 06:19:43
【问题描述】:
您好尝试编译 Objective C++/Protocol 代码,但编译失败并出现错误“Expected declaration specifier before protocol”和以下标头中所有 Objective C 代码行的类似错误。
#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
请注意,“Category”是一个 C++ 类。如果我从类中删除与协议相关的代码,那么代码编译得很好。有没有办法重组上面的代码并让它编译?
【问题讨论】:
标签: objective-c++