title: iOS: passing struct as parameter
body: <p>I have a struct declared in <strong>.m</strong> file of Class A:</p>
  
  <pre><code>typedef struct myStruct
  {
      size_t count;
  } myStruct;
  </code></pre>
  
  <p>And I am trying to pass it as parameter to a method in another class (Class B) in which I <code>#import</code> the <strong>.h</strong> file of class A (i.e. <code>#import "myClassA.h"</code>):</p>
  
  <pre><code>- (void)myMethodWithStructInClassB:(myStruct)aStruct
  {
  
  }
  </code></pre>
  
  <p>I got these error, respectively, when I did:</p>
  
  <pre><code>- (void)myMethodWithStructInClassB:(struct myStruct*)aStruct 
  </code></pre>
  
  <blockquote>
    <p>Declaration of type struct aStruct will not be visible outside of this
    function.</p>
  </blockquote>
  
  <pre><code>- (void)myMethodWithStructInClassB:(struct myStruct)aStruct 
  </code></pre>
  
  <blockquote>
    <p>Variable has incomplete type myStruct aStruct</p>
  </blockquote>
  
  <p>I have then tried using <code>#include</code> instead, still the errors exist. </p>
  
  <p><em><strong>By the way</em></strong>, what would be the difference using <code>#include</code> and <code>#import</code> in Objective-C? I have done some research, while they were answers but they were not helpful for my case here. Some say with #import we prevent double-including the header, but the arguments were not settled between answerers.</p>
  
  <p>I managed to fix the problem only when I did: <code>#import "myClassA.m"</code> (not <strong>.h</strong>).</p>
  
  <p>Can some one explain to me the <strong>(a)</strong> errors above and <strong>(b)</strong> the difference between the use of <code>#include</code> and <code>#import</code> in Objective-C and <strong>(c)</strong> why importing <strong>.m</strong> did the trick for me?</p>
  
  <p>In addition, which would be the proper way to do, when passing struct as parameter in Objective-C? i.e. <code>#import</code> or <code>#include</code>?</p>