Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Truly modal UIAlertView in iPhone?

I'm need run a couple of validations that depend on the decisions of the user (for example, if approve a purchase above the spending limit), and deny the "done" action if it's fail.

However, look like is not possible have a truly modal action like with other languages (like showmessage, alert(), etc) and everything is by delegates.

But then I don't know what to do. If the user push the "done" button, the program asks "Are you sure of this?" and he says "cancel" the flow continues and the view is pushed back!

How is solved this in the cocoa world?

like image 658
mamcx Avatar asked Feb 21 '09 21:02

mamcx


1 Answers

The solution is not to fight it, just break up your logic into two parts. If the user clicks cancel, do not execute the second part. If the user clicks OK/Continue, execute the second part.

The main problem caused by blocking the main thread is that the main thread is what handles events. The classic way of handling events can introduce strange event handling bugs, because you don't have one event loop, instead you have multiple event loops embedded inside of one another.

By using delegates, you can utilize one event loop (invoked via UIApplicationMain), and not have any of these event handling oddities crop up.

like image 108
Ecton Avatar answered Oct 04 '22 03:10

Ecton