“Expected a type” error pointing to the return type of a method

前端 未结 8 1675
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 06:02

I\'ve attempted to compile, but every time I do, one method throws a strange \"expected a type\" error. I have a method in the header:

-(ANObject *)generateS         


        
8条回答
  •  情歌与酒
    2020-12-13 06:32

    So, for some reason I was getting this error while trying to set a method with an enum type in the parameters. Like so:

    - (void)foo:(MyEnumVariable)enumVariable;
    

    I had previously used it like this and never had an issue but now I did. I checked for circular dependency and could find none. I also checked for typos multiple times and no dice. What ended up solving my issue was to adding 'enum' before I wanted to access the variable. Like so:

    - (void)foo:(enum MyEnumVariable)enumVariable;
    {
         enum MyEnumVariable anotherEnumVariable;
    }
    

提交回复
热议问题