views:

649

answers:

1

So I am trying to create a check that tries to connect to the WWW. when it fails it needs to then retry several times before the application gives up and quits. Each time it retries the user is propted with an UIAlertView with the options to Retry or Cancel.

So here is the problem.

I have a chain of actions in an NSOperationQueue, all the operations should fail with no connection. I"m using the NSoperation Queue so that the UI dosn't lock and the data is being processed in the background.

inside an NSInvocationOperation my method will hit [AlertView show], however this is not truly modal.

My operation then returns and continues through the chain of NSOperations, as there seems to be no way to return them with an Error value to stop additional processing. Eventually the UI catches up, displays the Modal AlertView, but i have no context of what has happened.

I am sure this is a common requirement. any ideas how to achieve this?

+2  A: 

If I understand you correctly, you want a modal version of UIAlertView, but only modal within the calling thread/NSOperation? A few problems with this:

  • You should probably only call interface operations from the main thread (easily addressed using performSelectorOnMainThread:)
  • Modal dialogs are not really part of the OS; you'll need to address this programatically.
Ben Gottlieb
genius! used the following and solved the problem flawlessly! [NoConnectionAlertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES]; while (!Dismissed) { [NSThread sleepForTimeInterval:1]; }
Bluephlame