ryanmaxwell / UIAlertView-Blocks

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

Add factory methods to return UIAlertView without showing it #13

Closed mokagio closed 10 years ago

mokagio commented 10 years ago

The factory methods to build and show the configured UIAlertView in one shot are pretty handy. In some cases though I'd like to build the alert view but don't show it straightaway.

I know that this is possible using the initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles: method and setting the tapBlock afterwards, but I like the simplicity of the factory method.

ryanmaxwell commented 10 years ago

Hi, thanks for the pull request. I'm trying to keep this library as simple as possible, and I don't think the upside of removing a single alloc call is worth the downside of increasing the API. Most of Apple's newer APIs only have a single way to create an object, whereas the older APIs typically had several, mostly for different memory-management (retain vs. autoreleased constructors).

mokagio commented 10 years ago

Cool, I see your point. Although my implementation moved the alloc into alertViewWithTitle:message:style:cancelButtonTiltle:otherButtonTitles:tapBlock:, making showAlertViewWithTitle:message:style:cancelButtonTiltle:otherButtonTitles:tapBlock: calling it under the hood. There would still be only one real way to create an object, but yes the API would increase in size.

Cheers :beers: