• 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: Sub classing.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sub classing.


  • Subject: Re: Sub classing.
  • From: Sandro Noel <email@hidden>
  • Date: Tue, 5 Dec 2006 11:03:54 -0500

Bill, that was my next question :)
thank you!

Sandro Noel.

On 5-Dec-06, at 10:59 AM, Bill Bumgarner wrote:

On Dec 5, 2006, at 7:36 AM, James Bucanek wrote:
The other way of doing this is to create a catagory. You can use this to tack your methods onto the implementation of NSMutableArray:

@interface NSMutableArray (StatusTableDataset) {
    - (id)getStatusObjectAtIndex:(unsigned int)index;
    ...

Once you do that, you can send any instance of NSMutableArray the message getStatusObject:. The only limitation of catagories is that you can't add instance variables to the class, only methods.

James' suggestion of subclassing NSObject and wrapping an instance of NSMutableArray is dead on.


The above works, but please don't use this pattern. It'll make a downright mess out of your code. It adds functionality to all mutable arrays across your program and not just the ones you are using to store the StatusTable stuff. This makes the code less reusable and harder to debug.

b.bum
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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)

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


References: 
 >Re: Sub classing. (From: James Bucanek <email@hidden>)
 >Re: Sub classing. (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: Sub classing.
  • Next by Date: Re: Synchronizing Thread Execution
  • Previous by thread: Re: Sub classing.
  • Next by thread: Re: Sub classing.
  • Index(es):
    • Date
    • Thread