Using DataAbstract and the RemObjects SDK with MonoTouch

One of the more interesting technologies to make its way into my brain in the last year has been MonoTouch. If you’re not familiar with it, MonoTouch is a set of tools and wrappers developed by Novell, the makers of Mono. It allows you to write apps for Apple’s iOS devices – the iPhone, iPad, and iPod Touch – in various .NET languages, including of course C# but also our own Oxygene (aka Delphi Prism).

A row from a Data Abstract table in the iPhone simulatorUp until now, there haven’t been many options for connecting to online services, or for data access. This is changing dramatically, with Data Abstract for Xcode, and coming soon to an iOS device near you, the ability to connect to your existing RemObjects SDK and Data Abstract servers with .NET and MonoTouch! The first glimpse of this new feature will be available in the next Data Abstract for .NET beta drop.

Please keep in mind that this is currently a work in progress. For example, there isn’t yet a MonoTouch-specific installer – the files you need can be found in a Windows install. Also, there are no templates or other IDE features in MonoDevelop. But hey, that’s what staying on the bleeding edge is all about, right?

This article will be focusing on writing a MonoTouch client for Data Abstract (DA). I’m going to assume that you’re familiar with the basics of MonoTouch and it’s development environment, MonoDevelop. Also, the sample is currently in C# – an Oxygene version will be available soon.

The first step is getting DA (and the RemObjects SDK) onto your Mac. Copy the entire “RemObjects SDK for .NET” and “Data Abstract for .NET” folders from your windows installation over to a convenient folder on your Mac.

Start a new MonoTouch project. Now you have a choice of which way to reference the RemObjects dlls. You can either:

  • add them as .NET assemblies – browse to the /bin/Monotouch folder in both the SDK and DA folders that you copied earlier. You need RemObjects.SDK.Monotouch.dll from the former and RemObjects.DataAbstract.Monotouch.dll from the latter.

  • add the projects to your solution, and then add them as project references – look for RemObjects.SDK.Monotouch.csproj, and RemObjects.DataAbstract.Monotouch.oxygene. Note that you have to have the Delphi Prism addin for MonoDevelop to go this route.

If you’re using a Relativity server, copy the RelativityDataModule.cs from the sample into your project folder and add it to your project; otherwise, copy the DataModule.cs.

Now to set up the connections. This is how it’s set up in the sample for Relativity:

var fDataModule =new RelativityDataModule();{ TargetURL = fSettings.RelativityTargetURL, DomainName = fSettings.RelativityDomain, SchemaName = fSettings.RelativitySchema, UserID = fSettings.UserID, Password = fSettings.UserID};

and for custom server:

var fDataModule =new DataModule(){ TargetURL = fSettings.CustomTargetURL, ServiceName = fSettings.CustomDataServiceName, UserID = fSettings.UserID, Password = fSettings.UserID};

To access data, you simple need to ask for the table that you want:

DataSet lDataset =new DataSet(); fDataModule.DataAdapter.Fill(lDataset, newString[]{ fSettings.TableName});

All the normal DA functionality should be there – dynamic WHERE, etc. The thing that’s missing at the moment is DA LINQ – runtime code generation is not allowed by the iOS license, so DA LINQ is on hold until we figure out how to do it’s magic a different way.