• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Extending NSMutableDictionary what am I doing wrong?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Extending NSMutableDictionary what am I doing wrong?
      • From: Greg Hurrell <email@hidden>
    • Re: Extending NSMutableDictionary what am I doing wrong?
      • From: Ondra Cada <email@hidden>
    • Re: Extending NSMutableDictionary what am I doing wrong?
      • From: Sherm Pendley <email@hidden>
  • Prev by Date: Why no willChange:valuesAtIndexes:forKey: when mutating array objects?
  • Next by Date: Re: Extending NSMutableDictionary what am I doing wrong?
  • Previous by thread: Why no willChange:valuesAtIndexes:forKey: when mutating array objects?
  • Next by thread: Re: Extending NSMutableDictionary what am I doing wrong?
  • Index(es):
    • Date
    • Thread