views:

81

answers:

1

Should instances of UIAlertView be reused when possible?

Or is wrapping them in a using-block the best practice?

  • For one situation, I created a (non-modal) MessageBox class (just like WinForms or WPF). I mainly use it for convenience.
  • Another situation is a custom UIAlertView that I've subclassed that has more advanced layout. I wire-up the Dismissed event to do some work on close.

Would either of these situation call for a different approach?

+2  A: 

I dont think there's any problem doing this in a using block - you may want to abstract out the handler so that you dont have alert box delegates all over the place that do the same thing.

then again the LoadingHUDView is a good example of needing to code out the functionality for more advanced things...

but either way - if you're reusing the same object but really changing it each time - there;s not much to be gained IMO

cvista
I agree with @CVista.. the uialertview is so lightweight that there's little gain for saving the object for later.. I usually just use it inside a block and that's good enough.
Eduardo Scoz