Getting protocol to an object via functions parameters
<p>Let's say we have following C++ code:</p>

<pre><code>struct ISomeInterface
{ 
  virtual ~ISomeInterface() {}   
  virtual void f() = 0;
};

class SomeClass : public ISomeInterface
{
public:
  void f() override
  {
      std::cout &lt;&lt; "Hi";
  }
};

void getObject(ISomeInterface*&amp; ptr)
{
  ptr = new SomeClass;
}

int main()
{
  ISomeInterface* p(nullptr);
  getObject(p);
  p-&gt;f();
  delete p;
}
</code></pre>

<p>It's quite straightforward and far from being perfect, but it draws the picture: getting a pointer to an interface to an object via function's parameters. </p>

<p><strong>How do we get the same with Objective C protocols?</strong> </p>

<pre><code>@protocol SomeProtocol &lt;NSObject&gt;
- (void)f;
@end

@interface SomeClass : NSObject&lt;SomeProtocol&gt;
- (void)f;
@end

@implementation SomeClass
- (void)f { NSLog(@"Hi"); }
@end
</code></pre>

<p>Thanks in advance.</p>