Variable with object of incomplete type C

I am trying to list as part of my method signature, and I get this disgusting 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?

+4
source share
2 answers

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

 enum { DEFAULT_CACHE_FILE, WEB_CACHE_FILE }; typedef unsigned long CacheFile; @interface DAO : NSObject -(NSMutableArray *) parseFile:(CacheFile) file; @end 
+12
source

Define it the same way as in the .h file:

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

(not with re-listing).

+4
source

Source: https://habr.com/ru/post/1401165/


All Articles