14 More Messages

Objects are very chatty by nature. They send and receive lots of messages about the work they are doing. In this chapter, you will learn about messages with arguments, nested message sends, and more.

A message with an argument

The TimeAfterTime program has an NSDate initialized to the date and time at which it is created. What if you want to represent a date in the future – say, 100,000 seconds from the first date? You can create such a date by sending the dateByAddingTimeInterval: message to the original instance of NSDate.

Notice the colon at the end of the dateByAddingTimeInterval: method’s name. This tells you that dateByAddingTimeInterval: accepts an argument. Methods, like functions, can have ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.