• 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: Confusing problems with inheritance in Objective-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Confusing problems with inheritance in Objective-C


  • Subject: Re: Confusing problems with inheritance in Objective-C
  • From: Darren Ford <email@hidden>
  • Date: Tue, 22 Jun 2004 16:03:31 +1000

On 22/06/2004, at 2:12 PM, Chris Hanson wrote:

On Jun 21, 2004, at 7:31 PM, Darren Ford wrote:
I've been programming in C++ for many years now, and I think the problem is probably that I haven't fully understood the Obj-C concept of inheritance and I'm trying to use my C++ knowledge to define my class. Can anyone shed any light on why I'm seeing this problem? I've attached my class definitions to the end of the email.

Another more general style critique on your code: You're creating a subclass of NSMutableDictionary, but it looks like you're doing so just to use a mutable dictionary rather than in order to create a new kind of mutable dictionary.
In such a case, it's generally better to just have a mutable dictionary that's referenced by an instance variable. That way you just have a has-a relationship rather than an is-a relationship.

I agree -- actually the reason for doing this way is that I want to use Cocoa's built-in property serialization class to be able to write an array of these 'objects' out to a file. Creating a new class and then creating a 'has-a' relationship with NSMutableDictionary won't work in my situation, as the NSPropertyListSerialization class is limited to NSData, NSString, NSArray, NSDictionary, NSDate, and NSNumber objects. By creating an is-a relationship with NSMutableDictionary I was hoping to leverage this, rather than having to write my own encoding methods.

Darren.
_______________________________________________
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: Confusing problems with inheritance in Objective-C
      • From: Chris Hanson <email@hidden>
References: 
 >Confusing problems with inheritance in Objective-C (From: Darren Ford <email@hidden>)
 >Re: Confusing problems with inheritance in Objective-C (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Value Transformers and MVC ...
  • Next by Date: Re: Redirect stderr to NSTextView
  • Previous by thread: Re: Confusing problems with inheritance in Objective-C
  • Next by thread: Re: Confusing problems with inheritance in Objective-C
  • Index(es):
    • Date
    • Thread