Here is my custom class:
PolygonShape : NSObject {
int numberOfSides;
int minimumNumberOfSides;
int maximumNumberOfSides;
}
My custom init method:
- (id)initWithNumberOfSides:(int)sides minimumNumberOfSides:(int)min maximumNumberOfSides:(int)max {
if (self = [super init]) {
[self setMinimumNumberOfSides:min];
[self setMaximumNumberOfSides:max];
[self setNumberOfSides:sides];
}
return self;
}
My dealloc method:
- (void) dealloc {
NSLog("Calling dealloc");
[super dealloc];
}
My sample code that crashes:
PolygonShape *shape1 = [[PolygonShape alloc] initWithNumberOfSides:6 minimumNumberOfSides:5 maximumNumberOfSides:9];
[shape1 release];
I've alloc-ed a PolygonShape increasing the retain count by 1 and then release-ing should decrement it to 0 and call dealloc, printing that message to NSLog but I just get EXC_BAD_ACESS. I'm able to access and change the fields in my object after creating it so everything up until there works. Many thanks for the help!