Luke Ryan Jernejcic

My objective-c return type is giving `Expected a type` error

April 17, 2012

Man, I hate when the solutions are so simple. Well for me, I had added the type into the implementation of a class, it was working fine. Then I needed to add it as the return type. Check. Update the interface so that callers can see it. Check. But then I was getting an error: Expected a type. Seemed weird as everything was working fine the implementation file.

In my defense I didn’t write this class, I inherited it. I didn’t realize that there were some imports in the implementation file that were not in the header file.

SOLUTION: Move the import from the implementation to the header file.

Make sure that you have the correct import. It’s one of those little bugs/mistakes that make you shake your head… at yourself.

FYI, a couple of other possible issues/solutions mentioned on this stackoverflow are circular imports or a typo in the previous line.


Written by Luke Ryan Jernejcic who lives and works in Austin Texas building useful things. Follow him on Twitter