I believe what I'm trying to do is referred to as a "deferred callback" at least in some paradigms.
Basically I need a way to call a method after another method returns. Something like this:
- (void)someMethod:data
{
[someObject doSomethingAfterCurrentMethodReturns]
}
I would like to be able to do this because a library for an external accessory that I have to use will crash the app if I do the thing I want to do within the method. This is noted in the documentation for the library. My current workaround involves an additional user interaction -- throw up UIAlertView and put the method behind a button click.
I've seen some libraries that seem to handle this. Is there a built in way to handle this in Objective C?
Depending on the number of parameters the method has you could use performSelector:withObject:afterDelay:
. Or you could start an NSTimer
and call the method when it fires.