I have to create an app for iDevice from another app what i created for android. I need to show a dialog for only two seconds. In android i uses this code:
public class ThreadW extends Thread{
private Handler handler;
public ThreadW(Handler handler){
this.handler=handler;
}
public void run(){
notifyM("start");
Thread.sleep(2500);
notifyM("stop");
}
private void notifyM(String message){
Message msg = handler.obtainMessage();
Bundle b = new Bundle();
b.putString("Dialog", message);
msg.setData(b);
handler.sendMessage(msg);
}
}
And handler:
public class HandlerWelcome extends Handler {
private DialogWelcome w;
private Context c ;
public HandlerWelcome(Context c){
this.c=c;
}
public void handleMessage(Message msg) {
Bundle bundle = msg.getData();
if(bundle.getString("Dialog").equals("start")){
w = new DialogWelcome(c);
w.show();
}else if(bundle.getString("Dialog").equals("stop"))
w.cancel();
}
}
And i use all in this way:
ThreadW tw = new Thread(new HandlerWelcome(c));
tw.start();
How can i do the same in objective c?
Here is a solution which uses Grand Central Dispatch (GCD):
However, you should create a custom alert dialog since iOS users won’t be expecting a standard alert dialog to automatically disappear.