iOS WWW call never resolving

I’ve stepped through and let it run for about 10 minutes and it constantly prints out False at Debug.Log(www.isDone);. It works in Editor and on Android. I know the code is quite ugly but I’m trying almost everything at this point and I’d be very grateful for any insights.

using UnityEngine;
using System.Collections;

public class CoroutineHelper : MonoBehaviour {

	private WWW response;
	private string sometext;

	public WWW runCoroutine(string url) {
		Debug.Log("Start coroutine");
		StartCoroutine(download(url));
		return response;
	}

	IEnumerator download (string atlasName)
	{

		WWW www = new WWW (atlasName);

		do{	
			Debug.Log("In while yield");
			try{
				Debug.Log("In try");
				Debug.Log (www.isDone);
				Debug.Log(www.text);

				Debug.Log ("After Catch area");
				if(www.error != " "||www.error != null){
					response = www;
					Debug.Log ("Error Break");
					break;
				} else if (www.text != " "||www.text != null)
				{
					response = www;
					Debug.Log ("Break");
					break;
				}
			}catch {
				Debug.Log("Continue");
				continue;
			}
			Debug.Log("Break2");
			//yield return null;
		}while(true);

		yield return www;
	}

}

1 Answer

1

Try doing it like this, yielding WWW to wait for it to complete before you check for errors:

WWW www = new WWW(atlasName);

yield return www; // Wait for WWW to finish downloading or time out

if (www.error == "" || www.error == null)
{
    // Success
}
else
{
   // Failure
}

Turns out I was asking the wrong question, but this answer is correct.