• 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 Distinguish Between Two TableViews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to Distinguish Between Two TableViews


  • Subject: Re: How to Distinguish Between Two TableViews
  • From: Conrad Shultz <email@hidden>
  • Date: Mon, 18 Oct 2010 13:47:33 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/18/10 1:27 PM, Michael Dautermann wrote:
>
> On Oct 17, 2010, at 4:29 PM, Chris Share wrote:
>
>> I'm new to Cocoa. I'm developing a simple application that contains two
>> TableViews. What I can't figure out is how to distinguish between the two
>> TableView pointers that are passed in to:
> There's a number of ways to do this....
>
> Easiest is to match the incoming tableView to the IBOutlet from your XIB/NIB, e.g.:

Additionally, at least two other approaches come to mind:

1) You can set tags in IB, and use NSView's tag method to compare, e.g.

if ([tableView tag] == TOP_TABLEVIEW_TAG) {}

(Assuming that TOP_TABLEVIEW_TAG is whatever you defined the
NSTableView's tag for, say, the top table view to be.)

I would still prefer Michael's IBOutlet approach, but thought I would
throw this out there.

2) If the tables serve even a remotely different purpose, I would
probably write two separate (delegate/dataSource) controller classes,
one for each table view.  This eliminates the need to test table
identity entirely, generally leading to cleaner code (and certainly
easier maintenance down the road).

If the two tables have aspects in common, there are various design
patterns that can help.  You could have each concrete controller class
derive from an abstract superclass.  Or you could have a separate class
that each controller calls upon when needed.  Such choices depend
largely on your specific objectives and application architecture.

Good luck!

- --
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFMvLJlaOlrz5+0JdURAnRLAJ9FR17WZdzdgs/YbUoPX91823hOxACePIh7
ypAn9yMU4i7zpQu3819Lpgc=
=9tmn
-----END PGP SIGNATURE-----
_______________________________________________

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

References: 
 >How to Distinguish Between Two TableViews (From: Chris Share <email@hidden>)
 >Re: How to Distinguish Between Two TableViews (From: Michael Dautermann <email@hidden>)

  • Prev by Date: Re: NSDictionary allValues not mutable
  • Next by Date: Re: AM/PM letter UNICODE issues
  • Previous by thread: Re: How to Distinguish Between Two TableViews
  • Next by thread: Re: How to Distinguish Between Two TableViews
  • Index(es):
    • Date
    • Thread