For the 3 years past, I hav’nt tried to create any iOS app because I am enjoying to deliver an app for WEB though many client are asking me if I can produce IOS app.

Here is my question:

Assuming my database is MYSQL or MSSQL, for an IOS app, which is best approach to access the database? thru REST API or DIRECT CONNECTION string to database?

Thank you for the future answer.


Put something in-between as you have no database driver for iOS.

how to create a rest api to the database server??

You create the restapi on the server.

sorry… can xojo create restapi and put it on the server???
i assume it is a console app

Of course. There are plenty of examples, so go and find them!

If you can use Airtable rather than MySql there is a great video and sample app on how to connect iOS to Airtable using their API:


I taught a class at XDC in Miami and gave out example code on how to communicate between and IOS Xojo App and a XojoCloud server with a MySQL database. If you attended XDC you should have access to what you need to get started.

[quote=439656:@Richard Duke]sorry… can xojo create restapi and put it on the server???
i assume it is a console app[/quote]

One option you should at least look at is Aloe which is can provide a great (and free!) framework for you. But then also look at the Add-Ons section of their downloads page. Specifically Luna Express, designed for making REST interfaces. Or depending on what you need to do, the AirTable support or Key-Value store too.

Regarding Aloe - it looks interesting, but doesn’t that in a way introduce the issue of learning and maintaining code for an additional framework - the very issue that brought many of us to simplify the process with Xojo?

In terms of learning, if you look at the example programs and add-ons, the learning curve is very low compared to trying to roll your own solution.

In terms of maintaining the code, again I’d surmise that dropping in a new Aloe upgrade every now and then would be less work then rolling your own solution.

Rolling your own can be more educational. But you would likely not implement all the features readily available free in Aloe.

I prefer JSON-RPC to REST because it’s protocol agnostic - HTTP, WebSockets or pure TCP.

I like to include a “service” member as well as the “method” as detailed here, it helps with routing and keeping related methods together.

So an example request might look like this:

"id": "abc", // your choice of id
"service": "seaCargo", // similar to a namespace
"method": "shipLocation", // the function to call
"params": ["Seago Bremerhaven"] // the arguments to pass to the function

And an example response:

"id": "abc", // for matching the response to a request
"error": null,
"result": {"longitude":1.3511000,"latitude":51.9637500}

Have a look at Xojo’s Webinars.


I’m approaching now to this argument. The first question I have is: How can I be sure no one else (except who uses my app) can access to the “middleware”?

Thanks in advance.

You need to provide ACCESS_KEY for each user or group. ACCESS KEY will be part of parameter on pulling data from web service.

I believed that one of good approach.

I use a consumer key, a consumer secret, a nonce, a timestamp and sign the request with a private key having uploaded the public cert to the provider (my app). And of course this all over SSL.