how to do it on objective-c: extending protocol and interface like in 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() { }
}
Is 开发者_开发知识库this possible on objective c? How to do it on objective-c?
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>
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.
As long you have this method public void doSomething()
defined in ChildClass
it is fine.
精彩评论