I've got this code:
Entry.h
#import <Foundation/Foundation.h>
@interface Entry : NSObject {
id object;
SEL function;
}
@property (retain) id object;
@property (assign) SEL function;
-(Entry*) initWithObject:(id)object selector:(SEL)function;
@end
Entry.m
#import "Entry.h"
@implementation Entry
@synthesize object;
@synthesize function;
-(Entry*) initWithObject:(id)obj selector:(SEL)sel {
self = [super init];
[self setObject:obj];
[self setFunction:sel];
return self;
}
-(void) dealloc {
[super dealloc];
if ([self object] != nil)
[[self object] release];
}
@end
And when I do this:
Entry *hej = [Entry alloc];
[hej release];
I get:
objc[2504]: FREED(id): message object sent to freed object=0xf5ecd0
Program received signal: “EXC_BAD_INSTRUCTION”.
What am I doing wrong?
(And this insert code thing at stack overflow doesnt work, unless I'm doing something wrong and you're not supposed to click "code sample" and then paste.)