Note that there are some explanatory texts on larger screens.

plurals
  1. POClass Composition Error?
    primarykey
    data
    text
    <p>I wonder if someone can explain where I am going wrong here, I am creating 2 objects (car &amp; engine) where the car object contains a pointer to the engine object. I know I am missing the obvious or just making some silly mistake, but I can't quite put my finger on it.</p> <p>NB: the code all works, except for the line that is comment ERROR.</p> <pre><code>// INTERFACE ------------------------------------------------------- ** @interface EngineClass : NSObject { } @end @interface CarClass : NSObject { EngineClass *engine; } - (void)setEngine:(EngineClass *)value; @end // IMPLEMENT ------------------------------------------------------- ** @implementation CarClass - (void)setEngine:(EngineClass *)newEngine { if (engine != newEngine) { [engine release]; engine = [newEngine copy]; } } @end @implementation EngineClass @end // MAIN ------------------------------------------------------------ ** #import &lt;Foundation/Foundation.h&gt; int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; CarClass *newCar_001; EngineClass *newEngine_001; newCar_001 = [[CarClass alloc] init]; newEngine_001 = [[EngineClass alloc] init]; [newCar_001 setEngine: newEngine_001]; // ERROR // Clean up [newCar_001 release]; [newEngine_001 release]; [pool drain]; return 0; } // END ------------------------------------------------------------- ** </code></pre> <p>The ERROR is ....</p> <p>run 2009-09-22 13:41:05.483 cocoa_engine_TEST[8606:a0f] 2009-09-22 13:41:05.485 cocoa_engine_TEST[8606:a0f] 2009-09-22 13:41:05.485 cocoa_engine_TEST[8606:a0f] -[EngineClass copyWithZone:]: unrecognized selector sent to instance 0x10010c8d0 2009-09-22 13:41:05.486 cocoa_engine_TEST[8606:a0f] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[EngineClass copyWithZone:]: unrecognized selector sent to instance 0x10010c8d0'</p> <p>cheers -gary-</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload