how to block a superclass method to be called to a subclass

后端 未结 5 1710
情歌与酒
情歌与酒 2021-01-19 03:37

I\'m extending the functionality of a class with a subclass, and I\'m doing some dirty stuff that make superclass methods dangerous (app will hang in a loop) in the context

5条回答
  •  攒了一身酷
    2021-01-19 03:46

    Just re-implement the unsafe method in your subclass and have it do nothing or throw an exception or re-implement it as safe, just as long as the new implementation doesn't call the unsafe superclass method.

    For the C++ crew in here: Objective C doesn't let you mark methods as private. You can use its category system to split up the interface into separate files (thus hiding 'private' ones), but all methods on a class are public.

提交回复
热议问题