2012-03-13 53 views
4

我想有一個枚舉作爲我的方法簽名的一部分,我得到這個可怕的錯誤在我的.h文件:變量與不完全型目標C

Declaration of 'enum CacheFile' will not be visible outside this function 

我有這個在我的.h文件:

@interface DAO : NSObject 

    typedef enum { 
     DEFAULT_CACHE_FILE, 
     WEB_CACHE_FILE 
    } CacheFile; 

    -(NSMutableArray *) parseFile :(enum CacheFile) file; 



@end 

我.m文件:

-(NSMutableArray *) parseFile:(CacheFile) file{ 
..... 
.... 
} 

而且我得到了我的M檔這樣的警告:

Conflicting Parameter types in implementation of 'parseFile:':'enum CacheFile' vs 'CacheFile' 

我在做什麼錯?

-(NSMutableArray *) parseFile :(CacheFile) file; 

(不枚舉一次。)

回答

12

移動@interface之外枚舉聲明,它更新到正確的Objective-C:

4

只定義它一樣,在您的.h文件中enum idiom(單獨的typedef)並修復方法聲明:

enum { 
    DEFAULT_CACHE_FILE, 
    WEB_CACHE_FILE 
}; 

typedef unsigned long CacheFile; 

@interface DAO : NSObject  
    -(NSMutableArray *) parseFile:(CacheFile) file; 
@end