Write and Read to a iOS device! Help

Hi everyone!

I’ve been working on a code for 1 1/2 day to use on iOS device.
I’ve been using testing it on a mac, but switching it iOS didn’t go well. I thought i could just switch from using Application.dataPath
to peristentDataPath and it would work. But NO!

I’m not familiar with using a serializer, so i followed this example Unity Noobs: XML - Writing to an existing xml file.

I used a StreamWriter and created a .txt file, is it a way to use these together.

I would really be greatful for a simple but a full example how to get this done :slight_smile:

Thank you in advance.

This save method works for me on both my mac and iphone.

public void Save() {
	Debug.Log (Application.persistentDataPath);
	
	XmlSerializer xml = new XmlSerializer (typeof(PlayerData));
	FileStream file = File.Create (Application.persistentDataPath + "/playerInfo.dat");
	
	xml.Serialize (file, playerData);
	
	file.Close ();
}