重複の可能性:
ObjectiveCで抽象クラスを作成する
Javaでは、抽象クラスを使用して、一連のクラスが同じ基本的な動作をするようにします。例:
public abstract class A
{
// this method is seen from outside and will be called by the user
final public void doSomething()
{
// ... here do some logic which is obligatory, e.g. clean up something so that
// the inheriting classes did not have to bother with it
reallyDoIt();
}
// here the actual work is done
protected abstract void reallyDoIt();
}
これで、クラスBがクラスAから継承する場合、実装するだけで済みますreallyDoIt()
。
これをObjectiveCで作成するにはどうすればよいですか?それは可能ですか?Objective Cで実行可能ですか?つまり、Objective Cではパラダイム全体が異なっているように見えるということです。たとえば、メソッドのオーバーライドを禁止する方法がないことを私が理解しているものとは異なります(Javaの「final」のように)。
ありがとう!