title: Use Objective-C without NSObject?
body: <p>I am testing some simple Objective-C code on Windows (cygwin, gcc).  This code already works in Xcode on Mac.  I would like to convert my objects to not subclass NSObject (or anything else, lol).  Is this possible, and how?</p>
  
  <p>What I have so far:</p>
  
  <pre><code>// MyObject.h
  @interface MyObject
  
  - (void)myMethod:(int) param;
  
  @end
  </code></pre>
  
  <p>and</p>
  
  <pre><code>// MyObject.m
  #include "MyObject.h"
  
  @interface MyObject()
  { // this line is a syntax error, why?
      int _field;
  }
  @end
  
  @implementation MyObject
  
  - (id)init {
    // what goes in here?
      return self;
  }
  
  - (void)myMethod:(int) param {
    _field = param;
  }
  
  @end
  </code></pre>
  
  <p>What happens when I try compiling it:</p>
  
  <pre><code>gcc -o test MyObject.m -lobjc
  MyObject.m:4:1: error: expected identifier or ‘(’ before ‘{’ token
  MyObject.m: In function ‘-[MyObject myMethod:]’:
  MyObject.m:17:3: error: ‘_field’ undeclared (first use in this function)
  </code></pre>
  
  <p><em>EDIT</em> My compiler is cygwin's gcc, also has cygwin gcc-objc package:</p>
  
  <pre><code>gcc --version
  gcc (GCC) 4.7.3
  </code></pre>
  
  <p>I have tried looking for this online and in a couple of Objective-C tutorials, but <em>every</em> example of a class I have found inherits from NSObject.  Is it really impossible to write Objective-C without Cocoa or some kind of Cocoa replacement that provides NSObject?</p>
  
  <p>(Yes, I know about GNUstep.  I would really rather avoid that if possible...)</p>
  
  <p><em>EDIT</em> This works:</p>
  
  <pre><code>// MyObject.h
  @interface MyObject
  @end
  // MyObject.m
  #include "MyObject.h"
  @implementation MyObject
  @end
  </code></pre>
  
  <p>Not very useful though...</p>