data source of table view fails

Hi everybody,
I have a small Test App with a table view “liste” of scroll view “liste”.
on awake from nib (Line 100 below) I want to initialize the variable contactsDataSource (Line 130).
The result is “item id 2”. When I do the same thing in another database (table from examples) I get “data source id 3”

I´m using IB 3.1 and I miss the tab AppleScript in the library, where the ASKDataSource used to be in 2.5.
My AppController is of type NSObject and not ASKDataSource what it should be, right?
Unfortunately all the software concerning “applescript studio” is not up to date.
It is from 2006 and doesn´t say anything about where to get a ASKDataSource in 3.1.

Nevertheless table view “liste” is properly connected to datasource of my AppController.
I don´t see what´s wrong. Any Ideas?

Greetings, Ronald

100 on awake from nib theObject
110 set theWin to window “main”
120 tell theObject #This is the window
130 set contactsDataSource to data source of table view “liste” of scroll view “liste” of theWin
140 tell contactsDataSource
150 make new data column at the end of the data columns with properties {name:“Eintrag”}
160 end tell
170 end tell
180
190 end awake from nib

Hi,

probably the problem is a wrong reference.
In your example with the tell block the reference is

data source of table view "liste" of scroll view "liste" of theWin of theObject

It’s always recommended to restrict reference tell block only for the appropriate lines.
I guess the tell theObject block isn’t needed at all


on awake from nib theObject
    set theWin to window "main"
    --    tell theObject -- #This is the window
    set contactsDataSource to data source of table view "liste" of scroll view "liste" of theWin
    tell contactsDataSource
        make new data column at the end of the data columns with properties {name:"Eintrag"}
    end tell
    --    end tell
end awake from nib

No Stefan, that was not the problem. It behaves the same way.

I copied the controller from the tables example table of type ASKDataSource and connected my TableView to this one.
Now I get the correct reference “data source id 3”.

I wonder where to get the controller ASKDataSource. It is not in the library of IB 3.1

Greetings, Ronald

The controller is just a normal NSObject object (the blue cube).
Go to Identity Inspector (⌘6) and type ASKDataSource in the class field. That’s all

This is what I tried before but it does not work.
Where did you get this approach from? It is not in the documentation like this.

It definitely works if I use the ASKDataSource from the Table example.

I just tried it.
But I can’t immagine, that you have to create the controller in IB.
It certainly will be created automatically while using the appropriate handlers
AppleScript Studio programmers are actually not involved in creating custom objects and controllers

Just typing in the word ASKDataSource cannot work.
You can only use Terms which are contained in the popUp next to the input field.
A table view with a data source must be connected it in order to work.

As I mentioned before, I don´t see how to get a data source object in Interface Builder 3.1

Greetings, Ronald

Sorry, it does work, I’ve tested it! After pressing return or tab the name of the controller changes to Data Source.
But maybe this behavior is because I use Interface Builder 3 but a project created in Xcode 2

Really?
I started my project in 3.1 and when I take a controller item and do the same thing I get contactsDataSource = null.
This is the value I defined with property theDataSource : null at the beginning.

really!

Watch the screenshots:
after dragging the NSObject
http://homepage.mac.com/stklieme/.Pictures/jpg/ASKDataSource1.png
after typing ASKDataSource
http://homepage.mac.com/stklieme/.Pictures/jpg/ASKDataSource2.png
after pressing return
http://homepage.mac.com/stklieme/.Pictures/jpg/ASKDataSource3.png

use


set contactsDataSource to make new data source at end of data sources with properties {name:"contactsDataSource"}
   tell contactsDataSource
       make new data column at the end of the data columns with properties {name:"Eintrag"}
   end tell
   set contactsDataSource to data source of table view "liste" of scroll view "liste" of theWin

you don’t need to add an object in interface builder to create a data source for a table, that’s when you get to objective-c