How to write and read from files on iOS?

I have a class that I used for my android implementation that reads and writes to text files on the device using File, FileWriter, and Scanner. For android, the file path was context.getFilesDir(). How do I do the same on iOS?

I used this piece of code which worked for me:

NSArray paths = Foundation.NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true);
String path = (String) paths.firstObject();

But if you have a look at the docs there is another method mentioned:
According to the Apple docs ( the second method should be the prefered one, but I think both will work.