开发者

iPhone: error in UIViewController interface declaration (expected '=', ',', ';', 'asm' or '__attribute__' before 'interface')

开发者 https://www.devze.com 2023-01-13 18:26 出处:网络
I have been working on this iPhone app for quite a while and everything has been working fine, but now all of the sudden, 开发者_Go百科I am getting this error in a file I don\'t remember editing (nor

I have been working on this iPhone app for quite a while and everything has been working fine, but now all of the sudden, 开发者_Go百科I am getting this error in a file I don't remember editing (nor do I remember editing anything relating to it, but it's possible.):

/Users/on_fire/BWOC 0.5/Classes/../BrowserViewController.h:29:
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'interface'

It's referring to the first line in this:

@interface BrowserViewController : UIViewController <UIWebViewDelegate>{

UIWebView *webView;
NSString *urlString;
UIActivityIndicatorView *activityIndicator;
UIBarButtonItem *refreshButton;

}

Here is the whole file (Pastebin).

The pastebin also has a link to a zip of my project if anyone want's to have a look at the whole thing.

I understand if you would rather not download a zip, so if you need any other files, just let me know and I will put them up separately as well.

Any help is greatly appreciated!


I suspect you accidentally broke your AppDelegate. I've seen this type of error show up in a file that's parsed after the AppDelegate, with the parser seeing the start of a new interface file as an error because the AppDelegate isn't closed off yet.

Edited to add

I haven't found the problem yet, but do see some problems I figured I'd point out.

In BrowserViewController.m:

if( urlString == @"invite.html" )

won't work the way you want, I suspect. You likely want:

if( [urlString isEqualToString:@"invite.html"] )

And this method:

- (void)webViewDidStartLoad:(UIWebView *)webView

has the webView argument that's the same name as your instance variable in the class. You should give it a different name here.

Same with:

- (void)webViewDidFinishLoad:(UIWebView *)webView

By changing those to myWebView throughout each of the delegate methods you're still referring to your own webView since it's being passed in.

Edited to further add

Unfortunately I don't see the error. I looked through all of the class files for anything suspicious but nothing pops out. My only suggestion is to consider the last change or two you made and look at the code there. Something completely innocuous can break the whole structure the compiler is expecting. Worst case, do you have a recent backup?


I had a quite similar situation.

This compile error came up on the @interface statement within an .h file. Alternatively it came on the preceding @class statement within the same .h file.

Apparently the error was thrown on the very first statement of that .h file that followed the usual #include directives.

It turned out that I happened to type an illegal character (in my case a 'd') at the beginning of the related .m file.

Like that:

//some comment
#include "something.h"

@interface myClass : itsSuperClass {

}

@end

d//some comment
#include "something.h"

@implementation myClass 

...
@end

Again, the error was thrown next to the @interface statement but it was caused by the single "d" character.

Hope that helps others.

Cheers Hermann


I didn't see a zip link on the pastebin page, but is it possible that this file is being included in a non-.m file (ie, a straight C, instead of Objective-C, file)?


I know this doesn't help but the header file doesn't seem to be the cause of the problem, the syntax is right. Maybe check in the m file


Are you importing classes in your header file? If so, you might be missing a semi colon in the one of the header classes you are importing.

A tiny bit more detail here:

http://bencoffman.com/blog/2010/09/01/errorExpectedAsmOrAttributeBeforeInterface.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号