OSX Bindings vs. .NET bindings

I have written many apps in Oxygene for .NET/WPF and these apps have used Data Abstract for data access and bindings. I find the .NET binding logic easy to understand. I do a DALINQ query to return an array/list, and then I can simply set my grid’s ItemSource property to this list or array. The underlying XAML gives the field names for which to bind, and more.

I am now trying to write my first MacOS app in Oxygene, again using Data Abstract. I have a few questions about binding that are confusing me.

First, when I go through the DA wizard to create a macOS client, I end up with the expected table definitions file, but also a dataacccess.pas unit which to me seems like overkill. First question - what is the purpose of the DataAccess.pas unit? I’m not using the briefcase features, and why would I load data from all tables???

I’ve since removed that unit, made my server connection via code, and I’ve been able to do a simple query without any problem, and getting an array of results returned.

NOw…on to binding.

in my XIB file that elements created, I have a ‘File’s Owner’,‘First Responder’ and ‘Application’ objects listed at the top. I’ve been reading through some cocoa binding tutorials, and they all tell me I have to bind an array controller to the ‘Application Delegate’ object…which I don’t have.

So, here is what i’m trying to accomplish as a first task.

1 - do a DA query to get an array of results back
2 - place a TableView on my main window, and bind the results to this showing the fields of my choice

What is the simplest, or best, way to do this in elements?

For the record, i’m using Fire to write this app, with the official 9.3 version of Elements.

Alan,

sorry fore the delay; stressful couple of days…

on any DADataTable, you can use rows or rowsFilteredWithPredicate to get an array of rows, possibly filtered locally. Of course you can also download the data filtered (if it’s to large to handle locally, also by passing a predicate or DA SQL, to e.g. getDataTable() withSQL().

that will be a standard NSArray and work with any cocoa bindings, eg with an NSArrayController (never used those myself) or an DAArrayDataSource.

DAArrayDataSource. is your best/easiest option there. just create one, set your table rows on it, and assign it to the delegate and dataSource properties of the NSTableView. That will give you a lot of default behavior.

If you wanna get fancy and customize a lot, you may want to implement INSTableViewDataSource and INSTableViewDelegste yourself, but that’s advanced stuff; I don’t think I ever needed rot do that in my DA based views, because DAArrayDataSource is pretty flexible.

hth.
marc

Thanks marc. I figured some things out yesterday but hadn’t run into the DAAreayDataSource. I will look into that next. Sorry to hear about stressful days! They do have a way of messing with ones work schedule!

1 Like