This is how to create a basic method that logs 'Hello World" to the console:
- (void)hello {
NSLog(@"Hello World");
}
The -
at the beginning denotes this method as an instance method.
The (void)
denotes the return type. This method doesn't return anything, so you enter void
.
The 'hello' is the name of the method.
Everything in the {}
is the code run when the method is called.