objective c - Does performSelector perform right away or is it scheduled to be performed? -


does performselector perform right away or scheduled performed iota later?

from doc

the performselector: method equivalent sending aselector message directly receiver.

so performs right away.

also doc, these 2 messages equivalent

id myclone = [anobject copy]; id myclone = [anobject performselector:@selector(copy)]; 

and both of them end compiled into

objc_msgsend(anobject, @selector(copy)); 

edit

after discussion originated under anoop's answer, think it's worth specifying not variants of performselector: executed right away. there's bunch of variants defined nsobject cause action scheduled. it's important notice holds true in case of 0 delay, stated documentation:

specifying delay of 0 does not cause selector performed immediately. selector still queued on thread’s run loop , performed possible.

to wrap up, here's relevant list of variants

variants right-away execution:

  • performselector:
  • performselector:withobject:
  • performselector:withobject:withobject:

variants execution scheduled (even 0 delay)

  • performselector:withobject:afterdelay:
  • performselector:withobject:afterdelay:inmodes:
  • performselectoronmainthread:withobject:waituntildone:
  • performselectoronmainthread:withobject:waituntildone:modes:
  • performselector:onthread:withobject:waituntildone:
  • performselector:onthread:withobject:waituntildone:modes:
  • performselectorinbackground:withobject:

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -