• 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
Subclassing NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subclassing NSMutableDictionary


  • Subject: Subclassing NSMutableDictionary
  • From: David Alter <email@hidden>
  • Date: Tue, 29 Nov 2005 09:59:09 -0800

I'm sure I'm missing something basic here but it is not hitting me. I want to subclass NSMutableDictionary. My init method wants to populate this dictionary with some data. But my sub class does not like it when I do this.

Here is the runtime error I'm getting. It does not make sense to me. I thought the point of subclassing was so I did not need to recreate methods that are in the super class. That appears to be what it is telling me to do.

2005-11-29 09:09:30.800 SubclassDict[2506] An uncaught exception was raised
2005-11-29 09:09:30.801 SubclassDict[2506] *** -setObject:forKey: only defined for abstract class. Define -[MyDictionary setObject:forKey:]!
2005-11-29 09:09:30.801 SubclassDict[2506] *** Uncaught exception: <NSInvalidArgumentException> *** -setObject:forKey: only defined for abstract class. Define -[MyDictionary setObject:forKey:]!


Here is the code

// *************************** MyDictionary.m file *************************************

#import "MyDictionary.h"


@implementation MyDictionary


- (id)init
{
[super init];
NSMutableArray * children = [[NSMutableArray alloc] init];
[super setObject:children forKey:@"children"]; // I also tried doing this using "self" and not "super". It resulted in the same error
return self;
}




@end



// *************************** MyDictionary.h file *************************************

#import <Cocoa/Cocoa.h>


@interface MyDictionary : NSMutableDictionary {

}

- (id) init;

@end


Thanks in advance for the help.

enjoy
-dave



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Subclassing NSMutableDictionary
      • From: Shawn Erickson <email@hidden>
    • Re: Subclassing NSMutableDictionary
      • From: "I. Savant" <email@hidden>
    • Re: Subclassing NSMutableDictionary
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: RE: Core Data Fetch request very poor performance ??!
  • Next by Date: Re: Is Apple's singleton sample code correct?
  • Previous by thread: Re: Queston about thread viewer
  • Next by thread: Re: Subclassing NSMutableDictionary
  • Index(es):
    • Date
    • Thread