Objective C - How can I create an interface?

前端 未结 4 524
别那么骄傲
别那么骄傲 2020-12-28 11:05

I need to be able to create an interface like you create in C# to enforce a group of classes to implement certain methods. Is this possible in objective c?

4条回答
  •  温柔的废话
    2020-12-28 11:29

    Interfaces are called protocols in Objective C

    If you go to add a class to your project you will have an option to create it as protocol and you will end up with something like:

    @protocol MyProtocol
    -(void) DoSomething;
    @end
    

提交回复
热议问题