Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HawaiiMacAddict

macrumors 6502a
Original poster
Dec 28, 2006
904
0
On one of my Macs of course
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
 

Attachments

  • Picture 1.png
    Picture 1.png
    106.9 KB · Views: 91
  • Picture 2.png
    Picture 2.png
    117.7 KB · Views: 95
  • Picture 3.png
    Picture 3.png
    140.7 KB · Views: 82
  • Picture 4.png
    Picture 4.png
    29.4 KB · Views: 99
  • Picture 5.png
    Picture 5.png
    47.3 KB · Views: 90
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
 

Attachments

  • Picture 3.png
    Picture 3.png
    29.8 KB · Views: 85
  • Picture 2.png
    Picture 2.png
    74.5 KB · Views: 101
  • Picture 1.png
    Picture 1.png
    90.9 KB · Views: 83
  • Picture 4.png
    Picture 4.png
    157.2 KB · Views: 79
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.
 
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
 
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
 

Attachments

  • Picture 1.png
    Picture 1.png
    77.4 KB · Views: 86
  • Picture 2.png
    Picture 2.png
    155.8 KB · Views: 101
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.