Code:
#import "NSButton.h"
@implementation NSButton
[webView setMainFrameURL:@"http://www.google.com/"];
@end
There are so many problems with this, I'm just going to list the problems. If you don't understand why it's a problem, that's just more reason why you need to use a book and start with the fundamentals.
Problems:
1. You haven't posted the code for your "NSButton.h". A .m file is only half of the total picture of any class.
2. You can't use the same name as a standard Apple-supplied class: NSButton is already used, and by reusing that name you are guaranteed to fail. Every class name must be unique.
3. You haven't put the code into a method or function definition. All executable code must be defined in the body of a method or function, between { and } that delimit the body of the method or function. If you don't know what a method or function definition is, then you won't know what that means. If I were to try explaining what it means, I would be repeating what a book or tutorial provides. Hence, the reason for following a book or tutorial.
4. You haven't shown the declaration for a webView variable. It might be in your "NSButton.h" file, or it might not. Impossible to say without seeing your .h file. If webView isn't declared in that file, then you don't have an actual variable of that name, so you'd need one before you can use it. Again, if you don't know what that means, you don't have the fundamentals, and any explanation I could give would repeat what a book or tutorial provides.
5. If you have a declared webView variable in your .h file, it will need to be an IBOutlet, otherwise it won't be connected to anything in your nib/xib file. If you don't know what an IBOutlet is, you're missing an important and fundamental part of the relationship between nib/xib files and the code residing in .h and .m files. And again, this would be explained by any book or tutorial that steps through fundamentals.
6. It turns out you paraphrased the code inaccurately:
is completely different from:
for the following reasons:
a. The placement of @ is different, and very important.
b. Class names (indeed, all names) in Objective-C are case-sensitive. NSButton, NSbutton, nsButton, and nsbutton are 4 completely different names. One of these is an Apple-defined name; all the others are not.
None of this is to discourage you from learning how to program. Rather, it is to encourage you to follow a guided approach using a book or tutorial that starts with the fundamentals. You wouldn't expect to hop in the cockpit of an F-15 (or even a basic Cessna) and fly it without any guidance or training. Learning to program is at least as complex a task as learning to fly a real aircraft. One difference is that the consequences of a crash are substantially less fatal in programming.