• 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: Objective-C and it's future
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C and it's future


  • Subject: Re: Objective-C and it's future
  • From: Scott Thompson <email@hidden>
  • Date: Mon, 10 Jul 2006 09:21:01 -0500


On Jul 7, 2006, at 7:42 PM, Thomas Davie wrote:

That is correct, but can you specify for me an NSArray containing only items that respond to a specific display method?

This is the sort of check that I would like to be able to do at compile time.

What you are asking is, "Show me how to build a bus that can only carry people that are at a particular convention".


In other words, it's not the Array's job to know what kinds of things it contains. It just holds things and transports them from place to place. If you wish to provide additional constraints on the things that can go into an array, you need a gatekeeper... someone checking for conference credentials before allowing someone onto the bus. You've created a special type of array and your code will have to reflect that.

The one way to do that is to wrap the NSArray in another class (a ConferenceBus class if you will). Then the ConferenceBus class can use a protocol declaration (id<ConferenceAttendee>) to ensure that everyone who can get onto the bus has the proper credentials.

With Objective-C you could handle that by subclassing NSArray, or by simply creating and object that contains an NSArray and have it respond to all the methods that you need for it to so that it can be substituted in the place of an NSArray at any point.

Scott

_______________________________________________
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: 
 >Objective-C and it's future (From: Thomas Davie <email@hidden>)
 >Re: Objective-C and it's future (From: Charlton Wilbur <email@hidden>)
 >Re: Objective-C and it's future (From: Rob Ross <email@hidden>)
 >Re: Re: Objective-C and it's future (From: "Shawn Erickson" <email@hidden>)
 >Re: Objective-C and it's future (From: Thomas Davie <email@hidden>)

  • Prev by Date: Re: NSDocument with NSMatrix crasher (10.4)
  • Next by Date: Re: Objects as keys NSMutableDictionary
  • Previous by thread: [Modertator] Re: Objective-C and it's future
  • Next by thread: Re: Objective-C and it's future
  • Index(es):
    • Date
    • Thread