• 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: newbie NSMutable dictionary subclass question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie NSMutable dictionary subclass question


  • Subject: Re: newbie NSMutable dictionary subclass question
  • From: Mike Abdullah <email@hidden>
  • Date: Mon, 17 Nov 2008 10:16:29 +0000

As a self-professed newbie, you almost certainly shouldn't be subclassing NSMutableDictionary. Can I ask your reasons for doing so?

On 17 Nov 2008, at 00:25, Bob Sabiston wrote:

Can the value part of a key-value pair in an NSMutableDictionary be a literal NSString, like @"name"?

It would seem so, because this works or at least doesn't crash:

	NSMutableDictionary *bobo;
	bobo = [[NSMutableDictionary alloc] init];
	[bobo setValue:@"root" forKey:@"name"];


However, I have a class derived from NSMutableDictionary, and it is crashing when I try to do the same thing:



@interface myClass : NSMutableDictionary { } @end

myClass *tree;
tree = [[myClass alloc] init];
[tree setValue:@"root" forKey:@"name"];


Why does that crash when the first does not? Are subclasses required to have member variables, or can they just have new functions? Mine don't have any variables, maybe that is the problem?


Thanks for any replies!
Bob

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: newbie NSMutable dictionary subclass question
      • From: Jean-Daniel Dupas <email@hidden>
References: 
 >newbie NSMutable dictionary subclass question (From: Bob Sabiston <email@hidden>)

  • Prev by Date: Re: Writing a more usable AppleEvent logger
  • Next by Date: Re: Set user agent for NSURL
  • Previous by thread: Re: newbie NSMutable dictionary subclass question
  • Next by thread: Re: newbie NSMutable dictionary subclass question
  • Index(es):
    • Date
    • Thread