Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Boneoh

macrumors 6502
Original poster
Feb 27, 2009
318
2
So. Cal.
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

NetBuilder.h

Code:
#import <Cocoa/Cocoa.h>

@class Network;
@class Node;

@interface NetBuilder : NSObject {
}

-(id)init;
-(void)dealloc;
-(IBAction)buildNetwork;

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

@end

NetBuilder.m
Code:
#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;

@end

// actual implementation

@implementation NetBuilder

@dynamic  network;
@dynamic  nodes;

- (id)init
{
	if ( self = [super init] )
	{		
		[self setNodes:[[NSMutableDictionary alloc] init] ];
	}
	
	NSLog(@"NetBuilder init");
	
	return self;
}
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
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.
 

Boneoh

macrumors 6502
Original poster
Feb 27, 2009
318
2
So. Cal.
Thanks!

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.