title: Optional arguments in Objective-C 2.0?
body: <p>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:</p>
  
  <pre><code>[aFraction print];
  </code></pre>
  
  <p>as well as this:</p>
  
  <pre><code>[aFraction print: someParameter];
  </code></pre>
  
  <p>in the same program.</p>
  
  <p>Apple's <strong>Objective-C 2.0 Programming Language</strong> guide contrasts Obj-C with Python and seems to say this is not allowed. I'm still learning and I want to be sure. If it <em>is</em> possible, then what is the syntax, because my second code example does not work.</p>
  
  <p><strong>Update:</strong>
  OK, I just made two methods, both named "print". </p>
  
  <p><em>header</em></p>
  
  <pre><code>-(void) print;
  -(void) print: (BOOL) someSetting; 
  </code></pre>
  
  <p><em>implementation</em></p>
  
  <pre><code>-(void) print {
      [self print:0];
  }
  
  -(void) print: (BOOL) someSetting {
      BOOL sv;
      sv = someSetting;
  
      if ( sv ) {
          NSLog(@"cool stuff turned on");
      }
      else {
          NSLog(@"cool stuff turned off");
      }
  }
  </code></pre>
  
  <p><em>the relevant program lines</em></p>
  
  <pre><code>    ...
      printParamFlag = TRUE;
  
  // no parameter
      [aCodeHolder print];
  
  // single parameter
      [aCodeHolder print:printParamFlag];
      ...
  </code></pre>
  
  <p>I can't believe that worked. Is there any reason I shouldn't do this?</p>