In Objective-C 2.0, is it possible to make a method where the argument is optional? That is, you can have a method call like this:
[aFraction print];
Slightly related you can have optional arguments. Meaning you can call a method with any number of arguments if you like. But that is a feature from C (varargs).
An example, is the NSArray message:
+ (id)arrayWithObjects:(id)firstObj, ...
Example of usage:
NSArray *myArray;
NSDate *aDate = [NSDate distantFuture];
NSValue *aValue = [NSNumber numberWithInt:5];
NSString *aString = @"a string";
myArray = [NSArray arrayWithObjects:aDate, aValue, aString, nil];
This is straight from the Apple docs. You indicate the end of all your arguments with a nil.