Swift - How to make and execute an AssyncTask?

0

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) {
    }
}
    
asked by anonymous 18.04.2016 / 21:24

1 answer

1

I think you're looking for a feature called Grand Central Dispatch (GCD), which takes care of the competition in Swift. Take a look at here .

    
19.04.2016 / 19:31