I made an Android app and I'm currently making a version of it for IOS, I'd like to know how to implement an AssyncTask in Swift and run it.
On Android I did this:
public void carregaBanner2(){ new LongOperation3().execute("");}
private class LongOperation3 extends AsyncTask<String, Void, String> {
public char getChar(char x){return x;}
@Override
protected String doInBackground(String... params) {
try {
//o que quero executar. . .
Thread.sleep(1000);
} catch (Exception e) {
Log.e("log_tag", "Error in http connection "
+ e.toString());
}
return null;
}
@Override
protected void onPostExecute(String result) {
try {
//depois de executado. . .
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
protected void onPreExecute() {
//Antes de executar. . .
}
@Override
protected void onProgressUpdate(Void... values) {
}
}