0
請參考下面的代碼:使用錯誤協議
//
// CacheObjectManagerImpl.h
#import <Foundation/Foundation.h>
//#import "CacheObject.h"
@class CacheObject;
@protocol ICacheObjectManager <NSObject>
typedef enum {
kSTRING,
kBYTEARRAY,
kCACHABLE,
kSTRINGVALUE
} CacheObjType;
CacheObjType *CacheObjectType;
@required
//- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
- (CacheObject *) createCacheObject:(NSString *)data url:(BOOL*)isURL savefile:(BOOL*)saveToFile downloadmgr:(ICacheObjDownloadMgr*) downloadMgr;
//-(CacheObject*) createCacheObject: (Cachable*) dataObject;
@end
@interface CacheObjectManagerImpl : NSObject {
}
@property(nonatomic,assign) id <ICacheObjectManager> delegate;
@end
它使用上面的類CacheObject下一個文件:
//
// CacheManagerImpl.h
#import <Foundation/Foundation.h>
//#import "CacheObject.h"
//#import "CacheObjectManagerImpl.h"
@class CacheObject;
@class CacheObjectManagerImpl;
@protocol ICachePurgeLogic <NSObject>
@required
- (void)runPurge: (NSDictionary*)cacheMap;
@end
@protocol ICacheManager <NSObject>
@required
- (void) put:(NSString*)key cacheobj:(CacheObject*)cacheObj;
- (CacheObject*)get: (NSString*)key;
- (void) clearEntireCache;
- (void) remove: (NSString*)key;
- (void) purge;
- (void) setCachePurgeCustomMgr: (ICachePurgeLogic*)cachePurgeLogic; **//ERROR: error: expected ')' before 'ICachePurgeLogic'**
@end
@interface CacheManagerImpl : NSObject {
NSNumber *timeToLive;
NSDictionary *cacheMap;
ICacheObjectManager *cacheObjMgr; **//ERROR: error: expected specifier-qualifier-list before 'ICacheObjectManager'**
ICachePurgeLogic *purgeManager; **//ERROR: error: expected specifier-qualifier-list before 'ICachePurgeLogic'**
}
@property(nonatomic,assign) id <ICacheManager> delegate;
- (void) getCacheManagerInstance: (NSNumber*) timeToLive;
- (ICacheObjectManager*) createCacheObjManager; **//ERROR: error: expected ')' before 'ICacheObjectManager'**
- (ICacheObjectManager*) getCacheObjManager; **//ERROR: error: expected ')' before 'ICacheObjectManager'**
@end
我無法理解爲什麼我收到上述錯誤。如果我包含頭文件,由於包含循環頭文件,我會得到更多的錯誤。這些編譯器錯誤有什麼可能的解決方法?或者我的代碼在協議傳遞和返回的意義上是完全錯誤的。
感謝,
ICachePurgeLogic和ICacheObjectManager聲明在哪裏? – MCannon