本文介绍了如何在objective-c上执行:扩展协议和接口,如java中所示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java中有这个:

I have this in java:

public interface SomeInterface {
    public void doSomething();
}

public class ParentClass {
}

public class ChildClass extends ParentClass implements SomeInterface {
    public void doSomething() { }
}

这在目标c上是否可行?如何在objective-c上做到这一点?

Is this possible on objective c? How to do it on objective-c?

推荐答案

听起来你只是问我怎么宣布这个课程符合协议吗?如果这就是你要问的问题,可可充满了例子。这是NSString的声明:

It sounds like you're just asking "How do I declare that a class conforms to a protocol?" If that's what you're asking, Cocoa is full of examples. Here's the declaration of NSString:

@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>

您可能会从阅读Apple的概述中获益,。它简短,涵盖了您需要了解的关于Objective-C语言本身的所有内容。

You would probably benefit from reading Apple's overview, The Objective-C Programming Language. It's short and covers pretty much everything you need to know about the Objective-C language itself.

这篇关于如何在objective-c上执行:扩展协议和接口,如java中所示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:55