Extending NSMutableDictionary what am I doing wrong?
Extending NSMutableDictionary what am I doing wrong?
- Subject: Extending NSMutableDictionary what am I doing wrong?
- From: Stefan Pantos <email@hidden>
- Date: Thu, 26 Feb 2004 13:04:31 +0000
Hi,
I think I must be, being really stupid. I want to extend
NSMutableDictionary and it just doesn't seem to be working. I think I
must have missed something about how you extend class. I haven't had a
huge amount of experience with Objective-C. What have I done wrong?
I get the runtime error: *** initialization method -initWithCapacity:
cannot be sent to an abstract object of class Page: Create a concrete
instance!
And no compile errors or warnings.
The code is:
-------------------- Page.h ------------------------
#import <Foundation/Foundation.h>
@interface Page : NSMutableDictionary
{
}
- (id)initWithTitle:(NSString*)title andText:(NSData*)text;
- (NSString*)title;
- (NSData*)text;
@end
-------------------- Page.m ------------------------
#import "Page.h"
@implementation Page
- (id)initWithTitle:(NSString*)title andText:(NSData*)text
{
self = [super initWithObjects:[NSArray arrayWithObjects:text, title,
nil] forKeys:[NSArray arrayWithObjects:@"text", @"title", nil]];
return self;
}
- (NSString*)title
{
//Not used yet
return nil;
}
- (NSData*)text
{
//Not used yet
return nil;
}
@end
------------------- Call it like so -------------------
currentPage = [[Page alloc] initWithTitle:@"title" andText:myPageText];
"Education is what remains after all school learning has been forgotten"
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.