Design Element
Comment on "CocoaHeads: Objective-C 2.0"
by Hamish — Nov 04
Recently I had cause to add an NSTimeInterval to an NSDate. If I was writing this in a language with operator overloading I'd have written:
endTime = startTime + delay

In the absence of operator overloading I instead have to write:
endTime = [[[NSDate alloc] initWithTimeInterval: delay sinceDate: startTime] autorelease]]

Luckily, in the presence of categories you simply have to write:
endTime = [startTime plus:delay]

Of course, someone (you or Apple) still has to write the method for this, but operator overloading doesn't change that fact.
Back to "CocoaHeads: Objective-C 2.0"
Design Element

Copyright © Scott Stevenson 2004-2015