December 2013
Beginner
576 pages
16h 4m
English
Because the type of object stored inside an id variable can be indeterminate at compile time, some tests are deferred until runtime—that is, while the program is executing.
Consider the following sequence of code:
Fraction *f1 = [[Fraction alloc] init];[f1 setReal: 10.0 andImaginary: 2.5];
Recalling that the setReal:andImaginary: method applies to complex numbers and not fractions, the following message is issued when you compile the program containing this line:
'Fraction' may not respond to 'setReal:andImaginary:'
The Objective-C compiler knows that f1 is a Fraction object because it has been declared that way. It also knows that when it sees the ...
Read now
Unlock full access