4

There are a lot of nice little functions in System.IO.Path like replacing a file extension, append to a path, getting a filename, getting a directory from a path in C#. Is there an iOS equivalent or somewhat close API?

thanks!

madmik3
  • 6,975
  • 3
  • 38
  • 60

2 Answers2

6

Yes, there is. Have a look at "Working with Paths" section in NSString reference.

To work with actual files you need to use NSFileManager class

Vladimir
  • 170,431
  • 36
  • 387
  • 313
1

NSString has a number of methods that allow you to manipulate paths.

It's not super elegant, but it's very useful.

NSString *textFile = @"readme.txt"
NSString *markdownFile = [[textFile stringByDeletingPathExtension] stringByAppendingPathExtension:@"markdown"];

// markdownFile is now "readme.markdown"
kubi
  • 48,104
  • 19
  • 94
  • 118