Cocoa TableView Binding w/ NSMutableArray of NSNetService - Assistance Requested

Discussion in 'Mac Programming' started by justindz, Jan 16, 2006.

  1. justindz macrumors newbie

    Jan 16, 2006
    I have an NSDrawer containing an NSTableView. In my application, I have an NSMutableArray populated with NSNetService objects picked up by my NSNetServiceBrowser. I want to bind the NSTableView to the contents of the array so that it displays the computer names discovered. This is for a game client's player list. I have verified that the browser accurately detects and stores the service entries but cannot--despite much wailing and gnashing of teeth--get the table to display any data. I don't have any errors or related warnings, though.

    I believe that I am missing either 1) a small detail or 2) a big, ethereal truth about Bindings. I've read pages and pages of online materials and tutorials and have adjusted by NIB and code several times according to instructions and reports of success. There seems to be a lot of frustration in this area--it would be nice if Apple put up a more comprehensive tutorial. It seems as if all the tutorials are incomplete in some way.

    Attached is a zip file of my project directory. I really appreciate any help--I've put several days into this with no progress. I started with a delegate/datasource approach to the table, got no where with that, switched to bindings and go no where with that. I'm frustrated enough to ditch my project and do something non-Mac native for the networking and GUI.

    Attached Files:

  2. caveman_uk Guest


    Feb 17, 2003
    Hitchin, Herts, UK
    I can't check your code just now as I'm on windows. One thing I will say is that in my general experience I've found that bindings are great if you do what Apple expects you to do. Try anything a bit different and you end up in a world of pain. Often it's just easier to write the damn datasource methods like you always did.

    One thing to be aware of is that you must make changes to your source array so that the bindings system is aware that you've done it. What may be happening is that the bindings are working but only see the empty array before you added the items to it. Check out this...
    This is from this page which is one of the best resources on bindings. Again, I haven't looked at your code but this has bitten me a couple of times. It's because your nib is often loaded (and the contents of the tableview) before you've actually set up your array.
  3. robbieduncan Moderator emeritus


    Jul 24, 2002
    I'm on Windows at the moment as well so can't check it out either. My initial thought would be that NSTableView does not know how to display a NSNetService. Try some sort of value transformer or create an array of NSStrings that are the name of the services?

Share This Page