I had my application working fine, then without doing anything, out of nowhere I got 2 errors in appDelegate.h
. One says this:
Expected
In my case, variable name was reserved to C++ because i change my files to *.mm
This message can also happen after pasting some code from Internet. There may be some invisible characters in your snippet.
So ONE of the solutions (see others above...) if you have the "Expected Method Body" error is to re-type the erroneous line from scratch.
I had the same problem. At last I found that in my main.m I had accidentally added a "-" character in the beginning of the file.
Removing the character solved the problem.
In my case I copied over my new methods in my implementation file over to the header file. I also copied over the @implementation Class(category) line and forgot to change it to @interface.
Basically the
Expected method body
is because there is a type/extra character somewhere!
For me it was because the name of Apple's pre-defined's method was mis-spelled.
Try closing Xcode and then reopening and doing a clean build.
If that doesn't fix it, it's possible you've got a circular reference in one of your header files.
This can happen when foo.h #imports "bar.h" and bar.h #imports "foo.h" (or sometimes its a chain of three or more header files importing each other in a circle) and it leads to spurious errors like the one you're seeing.
The solution is to try to avoid importing headers in your .h files, and instead use @class references for external classes in the .h files and put the #imports in the .m files instead.