- Home /
WWW error on ios
Hi
Recently I'm testing my project and find it always return bad url(www.error) when attempt to load file from local disk on ios simulator. But in editor, it works fine.
Here's a sample, it fail on simulator, but i can find this file from terminal, so the path is correct. Maybe we can't use "file://" in ios?
void Start ()
{
Write ();
StartCoroutine (Read ("file://" + Application.persistentDataPath + "/a.txt"));
}
void Write ()
{
File.WriteAllText (Application.persistentDataPath + "/a.txt", "Hello world");
}
IEnumerator Read (string path)
{
NGUIDebug.Log ("Reading: " + path);
WWW www = new WWW (path);
yield return www;
if (www.isDone && www.error == null) {
NGUIDebug.Log ("WWW result:" + www.text);
} else {
NGUIDebug.Log ("WWW error:" + www.error);
}
}
Answer by DeveshPandey · Sep 05, 2013 at 11:52 AM
You have to make your path as URL-friendly,
Try this :
IEnumerator Read (string path)
{
path = path.Replace(" ","%20");// this is extra line
NGUIDebug.Log ("Reading: " + path);
WWW www = new WWW (path);
yield return www;
if (www.isDone && www.error == null) {
NGUIDebug.Log ("WWW result:" + www.text);
} else {
NGUIDebug.Log ("WWW error:" + www.error);
}
}
for more detail - More Information & Problems
WOW! Haha... I admit never notice this could be a reason, but it is. THAN$$anonymous$$ YOU @DeveshPandey ! Is this the only translation for PATH? Should I work further to make others respect html encode style?
have you seen the links that I given to you, you can use them ints$$anonymous$$d of manual translating..
Your answer
Follow this Question
Related Questions
WWW in iOS does not set user agent header 1 Answer
Unity modules for iOS? 1 Answer
iPhone Controller Asset 0 Answers
iOS: Handheld.PlayFullScreenMovie 2 Answers