I'm reading this programming book with the following code
#import "Fraction.h"
int main (int argc, char * argv [])
{
@autoreleasepool {
Fraction *f = [[Fraction alloc] init];
[f noSuchMethod];
NSLog (@"Execution continues!");
}
return 0;
}
Apparently it's supposed to give me the following output:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Fraction noSuchMethod]: unrecognized selector sent to instance 0x103f00' * Call stack at first throw:'')
Instead I just get an error that says: No visible @interface for 'Fraction' declares the selector 'noSuchMethod'
Is this because I have a newer version of xcode, or am I doing something wrong? It seems pretty straight forward to me.
Edit:
Also... Would this following code work in the newest version of xcode?
int main (int argc, char * argv [])
{
@autoreleasepool {
Fraction *f = [[Fraction alloc] init];
@try {
[f noSuchMethod];
}
@catch (NSException *exception) {
NSLog(@"Caught %@%@", [exception name], [exception reason]);
}
NSLog (@"Execution continues!");
}
return 0;
}
Edit #2: