Please help my understand the tableview thing

Discussion in 'Mac Programming' started by HawaiiMacAddict, Jun 7, 2008.

  1. HawaiiMacAddict macrumors 6502a

    Joined:
    Dec 28, 2006
    Location:
    On one of my Macs of course
    #1
    Aloha everyone,

    I'm attempting to create a to-do app and I thought everything was good, but I can't get the entry in the text field to display in the table view. Please take a look at my code and let me know where I'm going wrong - this is driving my crazy. I tried to set up the console to indicate the new value being added to the array, but it indicates nothing. I also get no warnings or errors from XCode :eek:.

    Of course, there is the possibility that I don't fully understand the logic of the whole table view thing, but I thought this would work :confused:. I'm using XCode 3.1 and have included screenshots. Any assistance will be greatly appreciated.

    Mahalo in advance for your assistance,

    HawaiiMacAddict
     

    Attached Files:

  2. HawaiiMacAddict thread starter macrumors 6502a

    Joined:
    Dec 28, 2006
    Location:
    On one of my Macs of course
    #2
    Aloha everyone,

    I just saw one of my mistakes. I failed to associate the Add To-Do button with the addToDo method. Once I did that, the console printed out the new addition to the array, but it still doesn't get displayed in the table view.

    Once again, any and all assistance is greatly appreciated. Oh, I added a dealloc method for the array as well, but that doesn't get printed out on the console either :confused:.

    Mahalo in advance for your responses,

    HawaiiMacAddict
     

    Attached Files:

  3. mysticwhiskey macrumors newbie

    Joined:
    Mar 31, 2008
    #3
    Hi,

    A couple of things:

    1. An NSTableView object requires a data source to display its contents. The datasource object needs to implement the NSTableDataSource protocol. Your AppController class doesn't implement this protocol.

    2. You need to call the NSTableView's setDataSource method, and pass in the object that will be providing the data - in your case it will be the instance of AppController.

    However, I'm not sure how much is going on in your NIB (ie maybe you are doing (2) already).

    Have a look at Apple's documentation for NSTableView here.
     
  4. HawaiiMacAddict thread starter macrumors 6502a

    Joined:
    Dec 28, 2006
    Location:
    On one of my Macs of course
    #4
    Aloha mysticwhiskey,

    Thanks for your response. I will check the documentation for NSTableView on your link. I thought that passing the contents of the textField to myArray was sufficient, but I was obviously wrong.

    HawaiiMacAddict
     
  5. HawaiiMacAddict thread starter macrumors 6502a

    Joined:
    Dec 28, 2006
    Location:
    On one of my Macs of course
    #5
    Aloha everyone,

    I finally figured out my main issue. I had to connect my table view as both a delegate and its data source (in the nib) and rewrite the init method in my implementation file, as shown in the attachments.

    I'm posting this in case anyone else has the same problem and would like to see my solution.

    HawaiiMacAddict
     

    Attached Files:

Share This Page