Calling a method from another class in Objective C

后端 未结 5 969
鱼传尺愫
鱼传尺愫 2020-12-03 09:28

I have 2 classes, say class A and class B. Class B is created in class A. I have a method in class A, which needs to be executed in both class A and class B. Calling the me

5条回答
  •  有刺的猬
    2020-12-03 09:43

    You could make one class a delegate of the other but that is kind of arbitrary relationship-wise.

    Is there any reason not to use inheritance - both A + B subclass from Z - and Z is where your common method is? Then they could both call [self calculate];

提交回复
热议问题