iOS Development

Course No. 10-152-139

Chapter 14 — More Messages

Multiple arguments

  • As we saw before, Objective-C methods can have multiple parameters.

Nesting message sends

  • We saw this in chapter 12 with no explanation.
  • Does that look a little strange? It is sending messages that are nested and is very common in Objective-C.
  • Here’s what it’s doing. First, get some memory that holds an NSDateComponents object with the alloc method.
  • Then send the init message to the object to initialize and configure the object.
  • However, it is more concise and a full convention to do it this way.

Two ways to make an NSDate

  • First, with a class method
  • Now with the alloc class method and the init instance method.
  • These two ways are fully equivalent.

Sending messages to nil

  • This is a nice feature of Objective-C! You can send a message to nil and it doesn’t fail and it doesn’t create error messages.
  • The keyword nil is the Objective-C version of NULL in C.
  • In Objective-C you can do this.


  • The special keyword id is “a pointer to some kind of Objective-C object.”
  • A pointer to a specific class:
  • A pointer to a class where we don’t what the class is.