title: Get filename and extension from filepath programmatically cocoa?
body: <p>I know you can use NSBundle:</p>
  
  <pre><code> NSString *filePath = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"rtf"];
  </code></pre>
  
  <p>to get the filepath of a file, but how would I get the filename and extension (separately) from the filepath programmatically using NSBundle. </p>
  
  <p>For example, I may have: /Users/theuser/Documents/yourdocument.txt</p>
  
  <p>It is obvious that the file is 'yourdocument', and the extension 'txt'</p>
  
  <p>But I need to get the filename and extension from the filepath to use as an NSString.</p>
  
  <p>Your help is greatly appreciated!</p>