title: Rename a file if file already exists
body: <p>What is the best way in objective-c to rename a file if a file with a same name exists.</p>
  
  <p>Ideally, I would like to name untitled.png to untitled-1.png if a file named untitled.png already exists.</p>
  
  <p>I have included my solution below as an answer, but I think there should be a better way (built-in function) to do it.</p>
  
  <p>My solution is not thread-safe, and susceptible to race conditions.</p>