View Full Version : unrecognized selector sent to instance

Mar 18, 2009, 04:29 PM
I am getting the error "unrecognized selector sent to instance" but I can't seem to figure out the cause. :confused: I am new to Objective-c, and this seems to be something basic, but I'm not getting it. Why is setNodes not being recognized?

Thanks in advance!

[NetBuilder setNodes:]: unrecognized selector sent to instance 0x1b3e20


#import <Cocoa/Cocoa.h>

@class Network;
@class Node;

@interface NetBuilder : NSObject {


@property (retain) Network * network;
@property (retain) NSMutableDictionary * nodes;



#import "NetBuilder.h"
#import "Node.h"
#import "Network.h"
#import "Path.h"

// private methods

@interface NetBuilder ()

-(void)buildNodePaths:(Node *)node minI:(int)i1 maxI:(int)i2 minJ:(int)j1 maxJ:(int)j2 minK:(int)k1 maxK:(int)k2;
-(int)getDeltaIndex:(int)low startIndex:(int)start maxIndex:(int)max deltaIndex:(int)delta;
-(int)getIndex:(int)i andJ:(int)j andK:(int)k;
-(void)assignNodes:(int)n forZ:(int)z;
-(int)followPaths:(Node *)node;


// actual implementation

@implementation NetBuilder

@dynamic network;
@dynamic nodes;

- (id)init
if ( self = [super init] )
[self setNodes:[[NSMutableDictionary alloc] init] ];

NSLog(@"NetBuilder init");

return self;

Mar 18, 2009, 04:43 PM
Instead of @dynamic use @synthesize.

@dynamic is used if you are going to implement the accessor methods yourself. @synthesize is used when you want the compiler to do it for you.

Mar 18, 2009, 05:30 PM
Thanks a bunch, kainjow! That fixed the issue. Now I am on to finding the real bugs in my logic.

By the way, your profile pic is great, it reminds me of myself when I find a nasty bug. The hand on the head, "what was I thinking when I wrote THAT?" :D