How to prevent usage of other init methods other than my custom method in Objective-C
问题 Background - in my iPhone app I have a custom UITableViewController - I was going to pass some required config to it by extending the existing "(id)initWithStyle:(UITableViewStyle)style" method to an extended custom one. Question - what's the best way to ensure that the user of this custom controller class can only call my custom init method, and not initWithStyle or any other init methods? 回答1: You can override the init methods that you don't want to be used, and raise an exception there.