Create a basic method
suggest changeThis 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents