Methods and Messages in Obj-C
Like various languages Objective-C has the idea of objects. An object is a structure that holds data. These objects also contain functions that act upon the data. To trigger these functions you send a message to an object. A function that is triggered by a message is called a method.
In the 1980's Brad Cox and Tom Love wanted to include object-oriented ideas to the C language, so they build upon the idea of structs allocated on the heap and added a message sending syntax which resulted in the creation of objective-C. Objects can be very verbose and long generally since a complex working program can have hundreds of objects in memory simultaneously doing work and sending messages to each other.
There are many ways to create and call methods that takes multiple arguments. Firstly, the message send is surrounded by brackets and has two parts: A pointer to the object that is receiving the message, and the name of the method to be triggered.
Methods that take several arguments are different that ones taking only one argument such as NSDate not knowing what day of the month it is. So using another object such as NSCalendar that takes the day the month and another argument for the object to read. Specifically, a method by the name of ordinalityOfUnit:inUnit:forDate takes three arguments since the method has three colons. When programmers work through Objective-C they will typically line up the colons so that it is easy to tell the parts of the method name from the arguments. If you wanted to know the hour of the year instead of the day of the month; you’d use these constants:
NSU Integer hour = [cal ordinality:NSHourCalendarUnit; inUnit:NSCalendarUnit;forDate:now];