Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable with incomplete type objective C

Tags:

objective-c

I'm trying to have an enum as part of my method signature and I get this hideous error in my .h file:

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

I have this in my h file :

 @interface DAO : NSObject

    typedef enum {
        DEFAULT_CACHE_FILE,
        WEB_CACHE_FILE
    } CacheFile;

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



@end

My .m file :

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

And I get this warning in my m file :

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

What am I doing wrong ?

like image 726
London Avatar asked Dec 05 '22 17:12

London


1 Answers

Move the enum declaration outside of the @interface, update it to proper Objective-C enum idiom (separate typedef) and fix the method declaration:

enum {
   DEFAULT_CACHE_FILE,
   WEB_CACHE_FILE
};

typedef unsigned long CacheFile;

@interface DAO : NSObject    
   -(NSMutableArray *) parseFile:(CacheFile) file;
@end
like image 170
QED Avatar answered Dec 24 '22 03:12

QED