I am still having trouble with the WebKit tutori开发者_如何学Goal that I am trying from Apple's website: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/MultipleWindows.html
The .h file is as follows:
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
@interface MyDocument : NSDocument
{
IBOutlet id webView;
IBOutlet id textField;
}
- (IBAction)connectURL:(id)sender //Provides me with the error 'Expected ";" before "{" token'
{
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[sender stringValue]]]];
}
@end
Can you see anything that is wrong with that and why it is giving me a problem, please?
-- Thank you!
Yes! you've got your implementation in your header file. Move this to your .m file:
- (IBAction)connectURL:(id)sender {
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[sender stringValue]]]];
}
And replace it with the method declaration:
- (IBAction)connectURL:(id)sender;
This is an interface declaration, so you can't actually define a method there.
You need to only declare the method there, then put the definition in an @implementation
block.
精彩评论