2012-03-13 80 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