• 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: How to iterate through IBObjects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to iterate through IBObjects?


  • Subject: Re: How to iterate through IBObjects?
  • From: Sherm Pendley <email@hidden>
  • Date: Sun, 19 Sep 2004 16:51:04 -0400

On Sep 19, 2004, at 3:56 PM, email@hidden wrote:

So I guess I'm looking for someone to point me to a "standard" cocoa way of handling this.

The "standard" way of storing a nil (or NULL) value in a collection is to store an instance of the NSNull class, like this:


NSArray *ray = [NSArray arrayWithObjects:
	(nil != card1) ? [[card1 image] name] : [NSNull null],
	(nil != card2) ? [[card2 image] name] : [NSNull null],
	nil];

However, based on the description you gave, I get the impression that your app's design is flawed at a much more basic level. You shouldn't be storing your application's state as part of the view (i.e. IBOutlet) objects, hence there shouldn't be any need to query and store their attributes at all.

What you should be doing is storing all of the state information, such as a list of the cards in a player's hand, the position (i.e. face-up, hidden, etc.) of each card, etc. in one or more model objects. Your view objects should do nothing more than generate events that controller objects will respond to, and query the model object(s) for the information they need to display themselves - the model object should not depend on the view object in any way, or even on the presence of a view object.

Take a look at your model classes - when you can take the same classes, lift them out of your app and put them into a server app that gets input from and provides data for a *completely* different interface than what you have now, then you'll have well-designed model classes.

For more about Model-View-Controller (MVC) design, see Apple's site:
<http://developer.apple.com/documentation/Cocoa/Conceptual/ AppArchitecture/Concepts/MVC.html>


If I'm mistaken about your app design, I apologize for the MVC sermon. ;-)

sherm--

_______________________________________________
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: 
 >How to iterate through IBObjects? (From: email@hidden)

  • Prev by Date: NSBrowserCell and objects
  • Next by Date: Re: modal window + sheet
  • Previous by thread: How to iterate through IBObjects?
  • Next by thread: NSBrowserCell and objects
  • Index(es):
    • Date
    • Thread