Mario
Mario

Reputation: 2451

Subclassing UIActionSheet

I want to subclass UIActionSheet so I can add blocks API.

I want to subclass so I can still enjoy the "self retained" behavior of the action sheet.
I prefer it than creating an object that will hold a UIActionSheet as an instance, because then I will need to hold a reference to that object, so it won't be released.

So my question is, can I subclass the UIActionSheet (will Apple allow that)?

I just not sure cause I saw that in the UIActionSheet class reference:

Subclassing Notes:
UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

Upvotes: 2

Views: 934

Answers (2)

tanz
tanz

Reputation: 2547

The answer is NO. If you subclass UIActionSheet your app is likely to be rejected when sent to the Apple App Store. You need to implement your own custom action sheet if the UIActionSheet doesn't suit your needs as it is. The same applies to UIAlertView.

This is clearly stated in the documentation:

UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

Upvotes: 1

Ashley Mills
Ashley Mills

Reputation: 53101

Absolutely you can subclass UIActionSheet. I've written (and used) my own subclasses of this and UIAlertView for exactly the reason you state.

UIActionSheet is not designed to be subclassed

…doesn't say you can't subclass, just that it's not designed for that.

As long as you're not using private methods, you'll be fine!

Upvotes: 0

Related Questions