Table view sample code???

Hi you all!
I searched this in the forum for a long time but I didn’t find it… Can anyone tell me how to create a table view (just one row) in ASObjC?? In AS Studio it took just one single line of code setting the contents of a table to an array like this {“one”, “two”, “three”}. I managed to do almost everything in ASObjC but tables… it’s frustrating…

Thanks a lot in advance

If you use bindings, the code is about the same:

script SimpleTableAppDelegate
	property parent : class "NSObject"
	property theData : missing value
	
	on applicationWillFinishLaunching_(aNotification)
		set my theData to {"one", "two", "three"}
	end applicationWillFinishLaunching_
	
end script

In IB, you would need an array controller with it’s content array bound to theData, and the column in the table bound to the array controller’s arranged objects. That’s all it takes.

Ric

After Edit: I’m not sure what you meant by “one row” — the example I gave above creates a table with one column having three rows of data. If you want multiple columns, then you would use a dictionary instead of an array, and bind each column to a key in the dictionary.

By far the best, fastest and cheapest way to learn about tables, and all kinds of other useful stuff, is to buy Shane Stanley’s PDF book “AppleScriptObjC Explored”. It’s a steal for only 30 bucks – you won’t regret it! Includes lot’s of useful code you could simply copy & paste.

/Harald

Well, I meant to say that even just one row would have been enough, for the example…
Your tip worked like a charm, fantastic! Thank you very much!! :smiley:

I agree ! It’is a very very good PDF Book.
It help us a lot to learn more about ASObj-C

I have no doubt it is the best resource ever… I think anyone who has never developed in AppleScript and/or used XCode and Interface Builder should have that book.

…can we say the same thing for the rest of them who have been Applescript/Mac developers for years and now need just few informations?
(This forum’s name is “AppleScriptObjC and XCode”, and a forum is a place where people should share their knowledge… if they want, of course) :slight_smile:

Yes! You will save time and struggle.

Personally I’m not struggling at all… :slight_smile:
PS> Saving time… saving struggle… and what about saving money? :stuck_out_tongue:

I’m joking… I’m just joking… :cool:

FWIW, it actually assumes reasonable familiarity with AppleScript. I certainly wouldn’t advise it for anyone who has never developed in AppleScript.

I have no doubt it is a great book, everyone says it is wonderful so it surely is. If someone has lots of questions about ASObjC they certainly should buy that book, of course. In my personal “scenario” I only needed a few suggestions so I prefer saving those 30 bucks to buy one of your next books about something I don’t know at all. :slight_smile:

Even if I don’t need the whole book about ASObjC, I want to thank you anyway because you have made something extremely useful for most people. :slight_smile: