Sorry if this is a newbish question, but I have so far got used to make programs only by using very standard features that concern key-value coding. I have this simple piece of code:
When ran, the debugger gives me a runtime error at the "[pool release]" line. Why is that? What is key-value coding in general, and how can I make my classes use it?
Code:
#import <Foundation/Foundation.h>
@interface test:NSObject{
NSMutableString *simpleValue;
NSMutableArray *simpleArray;
}
@end
@implementation test:NSObject
- (id) init {
self = [super init];
if (self != nil) {
simpleValue = [NSMutableString stringWithString:@"hello world!"];
simpleArray = [NSMutableArray arrayWithObjects:@"hello 1", @"hello 2", nil];
}
return self;
}
- (void) dealloc {
[simpleValue release];
[simpleArray release];
[super dealloc];
}
@end
int main (int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
test *t = [[test alloc]init];
[t takeValue:@"hello again!" forKey:@"simpleValue"];
NSLog(@"%@",[t valueForKey:@"simpleValue"]);
[pool release];
return 0;
}
When ran, the debugger gives me a runtime error at the "[pool release]" line. Why is that? What is key-value coding in general, and how can I make my classes use it?