title: Determine filetype of path string in Swift
body: <p><strong>I need to decide the filetype of a file from the filename which I get in string.</strong> So I decided to get the last three characters of the String to decide what filetype it is. How do I get the last three characters in a String. For example</p>
  
  <pre><code>var fileName = "test.pdf"
  </code></pre>
  
  <p>I need to get the <strong>pdf</strong> alone. <strong>Is there any other better way to check for the file type other than this. Please suggest me that also.</strong> Because I think, I won be able to recognise if the filetype comes in four characters like <strong>"jpeg"</strong> and other stuff. Thanks in advance.</p>