1

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
okami
  • 2,093
  • 7
  • 28
  • 40
  • IMHO, construction like this in real code is sign of not mature design. But it's not the case probably. – Roman Feb 17 '10 at 21:46
  • I see that you edited the question to clarify the context. That's a good thing, but this is actually not related to Java. So I removed the tag. In the future, please try to be as clear as possible about the context of the question in the first place. Do not use only vague hints in the title or tags. – BalusC Feb 17 '10 at 22:15

2 Answers2

2

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.

Chuck
  • 234,037
  • 30
  • 302
  • 389
1

As long you have this method public void doSomething() defined in ChildClass it is fine.

fastcodejava
  • 39,895
  • 28
  • 133
  • 186