• 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: DataSource class of NSTableView - weird
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DataSource class of NSTableView - weird


  • Subject: Re: DataSource class of NSTableView - weird
  • From: Kai <email@hidden>
  • Date: Tue, 11 Nov 2003 11:12:20 +0100

First, you forgot to initialize databaseTables to nil. It may contain any value, even garbage, which means your !databaseTables test will just fail and you find yourself working with an uninitialized pointer variable that points to an arbitrary memory location instead of to an array.
Yes, correct. I added it!

Second, you are creating *two* instances of your data source. You have one in your NIB file (the blue box), and one that you're creating inside TestApp's awakeFromNib method. Your TestApp will use the one it created, which isn't hooked up to the table view, and then IB will
create a second one, which is hooked up to the table view.
Ooohhh, yes it's right!

1) Delete the blue box "MyDataSource" from the NIB file. However, then you'll have to manually set up the table view's data source and MyDataSource's TableView outlet.
2) Turn the MyDataSource* in TestApp into an IBOutlet and remove the code that creates a MyDataSource in TestApp.awakeFromNib. Then you can hook up the outlet of TestApp to the blue box "MyDataSource" in your NIB and you'll have only a single object, as it should be.
I've used the second method. It's clearer.

PS - I suppose you have a valid reason for having separate objects of MyDataSource sharing the same array. Typically, each data source object would have its own array, and you'd share the data source between different table views, or whatever.
One array for any data source with one field.

Ok, it works correctly now, thanks for opening my eyes! :) I'm developer since ten years for many programing languages, but this happens me less. Sometimes one doesn't see the forest, because of the many trees! :)

Thanks for help!
Kai
_______________________________________________
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.

References: 
 >DataSource class of NSTableView - weird (From: Kai <email@hidden>)
 >Re: DataSource class of NSTableView - weird (From: "M. Uli Kusterer" <email@hidden>)
 >Re: DataSource class of NSTableView - weird (From: Kai <email@hidden>)
 >Re: DataSource class of NSTableView - weird (From: "M. Uli Kusterer" <email@hidden>)
 >Re: DataSource class of NSTableView - weird (From: Kai <email@hidden>)
 >Re: DataSource class of NSTableView - weird (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: Re: itunes for windows HOWTO ???
  • Next by Date: Re: NSView subclass bindings? NSTextView? (WebView?)
  • Previous by thread: Re: DataSource class of NSTableView - weird
  • Next by thread: Re: DataSource class of NSTableView - weird
  • Index(es):
    • Date
    • Thread