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

Re: Subclassing NSMutableDictionary


  • Subject: Re: Subclassing NSMutableDictionary
  • From: "I. Savant" <email@hidden>
  • Date: Tue, 29 Nov 2005 13:13:23 -0500

David:

This seems an awfully strange way of doing things. How about in your controller class defining a method like so:

- (NSMutableDictionary *)preloadedDictionaryWithChildren:(id)children

... and creating / populating / returning the dictionary from there. It just doesn't strike me as a good idea to subclass a basic container just to get a preloaded instance of that container.

--
I.S.


On Nov 29, 2005, at 12:59 PM, David Alter wrote:

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:
40gmail.com


This email sent to email@hidden

_______________________________________________ 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
References: 
 >Subclassing NSMutableDictionary (From: David Alter <email@hidden>)

  • Prev by Date: Re: Subclassing NSMutableDictionary
  • Next by Date: Re: Subclassing NSMutableDictionary
  • Previous by thread: Re: Subclassing NSMutableDictionary
  • Next by thread: Re: Subclassing NSMutableDictionary
  • Index(es):
    • Date
    • Thread