ryanmaxwell / UIAlertView-Blocks

Category on UIAlertView to use inline block callbacks instead of delegate callbacks.
MIT License
425 stars 58 forks source link

Nested/Chained UIAlertView blocks? #11

Closed kwade101 closed 10 years ago

kwade101 commented 10 years ago

Greetings. Nice UIAlertViews framework. I like it but am I having one issue.

If I have a method (runThing1) that pops up a UIAlertView with a block with a button where tapping it executes another method (runThing2)...

...and now runThing2 ALSO pops up another UIAlertView with a block, then the app crashes. I'm guessing it's a nesting/threading issue:

EXC_BAD_ACCESS in didPresentAlertView() here: id originalDelegate = objc_getAssociatedObject(self, UIAlertViewOriginalDelegateKey);

Any ideas?

ryanmaxwell commented 10 years ago

is the second method doing any work on a background thread? If so, UI must always be on the main thread, so try wrapping the call in a GCD block

dispatch_async(dispatch_get_main_queue(), ^{
    [UIAlertView bla bla];
    });

If this doesn't help - a small sample project would be appreciated :)

kwade101 commented 10 years ago

Yes, that appears to have done the trick. I swear I tried that but... well, it's working now! Many thanks for the quick reply.