ios - How do I wait for a method to finish before calling it again? -


I am creating a simple message application using the pars structure I have displaymessages Is a method called it every time the phone receives a push.

However, as this message is working in a parsing database, I do not want to call it again if it is already running. I want to wait until it ends and then I am calling it.

I am using the following code:

  - Receive (zero) loop {[auto display message]; }  

and:

  - (zero) display message {// code here}  

if received Gone Push is said to be before I call it displaymessages before I want to wait. Can someone point me in this right direction to me?

UPDATE

I tried to use the NSOperationQueue method and felt that though it works to wait for it display Message is not a required behavior in displaymessages I have: [PFObject deleteAllInBackground: toDelete]; In fact it requires me to wait for the phone to be completed before displayMessages again.

Create a NSOperationQueue and set maxConcurrentOperationCount 1 from Implement your data access method as an operation (potentially block-type operation) and submit it in the queue (I like it better than GCD because you can cancel or test the number of items already in the queue

Note that if the method actually displays things, then you queue for the main UI work.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -