Table View Question

Like Craig’s Table View Demo, he used NSImage to put a green indicator image and a red indicator image to show the status of books. I wanted to learn about Table View and make a small little task application. I want to have those 2 images as statuses of a task, but have them change by clicking on the image in the Table.
Would I use a notification method? Do I need to add more classes?
What notification method would I use? How would I change it in the data source as a table?


I recommend to use NSButtonCell instead of NSImageCell.
Make the button shape invisible and assign the image via Cocoa bindings.

OK… Now I got a check mark (which is OK, I’m only a beginner) with a removed title. Now there is a “Status” column with check marks that are properly checked (I removed the NSImage part in Xcode). What do I do to have a action called when a check mark is checked?

I made a tiny project in Objective-C to show how to bind the state of NSButtonCell in NSTableView.
It uses NSArrayController and a custom class. The code is very primitive, no error handling at all.

You can download it here

Hope it helps

Great! This is too strange for me to translate. D:
I’ll see, ask for help when needed.

A few questions:

  1. What is the - (id)init in ASOC? Is it just on init() ?
  2. What are
[super init];


[super dealloc];


- (NSImage *)statusImage

I KNOW I’m not going to get a response.

The bit in parentheses before the method name is the type returned by the method. id is a sort of object wildcard.

[super init] translates as roughly “continue init()”. But the role of init is to give initial values to properties in Objective-C, whereas AppleScript properties already have an initial value. So there’s usually no need for an init() in AS classes.

dealloc does nothing in in garbage collected apps, so you can skip that too.


That’s the start of a method: the - means it’s an instance method, the NSImage * tells you it will return an image, and statusImage is its name. Stephen has bound the image of the button to this.

Keep in mind that there’s more than one way to do this.

Confusing. :frowning: Can I get a copy of that project of Stefan’s in ASOC from you, Shane? I really need it, simply for learning purposes.

I’m not sure that a translation is what you want, depending on how you are going to handle the rest of the table.

But if you just want to switch between read and green, I suggest you set the type of the NSButtonCell to Switch and set the image to red and the alternative image to green – no need for any code.

Yes, but if I wanted to save the list into User Defaults, wouldn’t I need code?
And I want to have a way to change the list in the table, just by double-clicking and typing, like Stefan’s.

Unfortunately this doesn’t work in NSTableView

OK… I’ve became a little picky because I couldn’t do the simple “double click and change the data” in the Table View.
I’ve found an EASY ways around that. If you type in information as if your just adding a new task while a item is selected, you can click on “Replace” to replace that selected item. Also, if you want to change the status, you can click a button to change an item’s status. Here is the project: Project 2.3 MB (

I’ll try to make my app save. That can’t be too hard.

I can only speak from the ObjC side: Implement the NSCoding Protocol, then you can save anything

I’ll get it from “NSUserDefaults.” Shouldn’t be that hard.

Hmmm. It’s working fine here. How else would a checkbox work?

I guess this is new in 10.6 respective XCode 3.2.x. In my 10.5.8 SDK it doesn’t work