Actually, you can get compile-time warnings about calling a method on a subclass. Use the __attribute((deprecated))
attribute. If you want people to use -initWithPizza:
instead of -initWithFrame:
, do this:
@interface MyView : UIView
- (id)initWithPizza:(MyPizza *)pizza;
@end
@interface MyView (Deprecations)
- (id)initWithFrame:(CGRect)frame __attribute((deprecated("Use initWithPizza: instead")));
@end
Putting the -initWithFrame:
declaration in a separate category is necessary to avoid Xcode complaining that you declared the method in the header but didn't implement it. Since you're just inheriting it from the superclass, that's fine; you don't have to implement it at all. But if you want to implement it to throw an exception, or call through to -initWithPizza:
with a default argument, that's fine.
Of course, this won't stop UIKit from calling -initWithFrame:
if it was already going to do so. But if you can guarantee that won't happen, then you're fine.