Developer’s Life 03-04.03.2018

Hello World and Hello Dear Readers. I am Software Developer and I have also blogged about stuff not related to programming, because not everything is code (at least not programming code). I decided to start writing more technical stuff. As a part of this I’ll try as much as I can to write something in the programming area each day.

If you are following me, you’ll know that one of my latest products is a tool for Generating Database related code. My primary focus in programming for some years is Java, Web and Mobile stuff. So, as a step in this direction I am extending my tool to generate database code for the Apple’s Swift programming language.

Currently I have touched two ways to store structured data on the iOS – Core Data and Sqlite (FMDB library). There may be some more ways, but I’m stopping to these for now.

Core Data framework uses a model XML file/files for describing your domain objects and and the xcode development environment generates the model classes and the other necessary stuff. I tried to generate the model files directly – they are xml files wrapped in some other file. It is a zip like file, but not exactly, because, when I generated a Zip file from my tool, the IDE didn’t succeed to recognize it. So I left it to the state where the tool can generate only the XML describing the model. You could open some created by the IDE file and copy and paste the XML descriptions. I marked it as “early alpha” because it is not fully tested (even by me). Currently there is a problem when I run an app with Core Data Framework included. The compiler is whining about some swift stuff that I couldn’t fix for know. Maybe because my mac is 10+ year old. I may check it out some time in the future when I upgrade my machine or when there is need for it.

The second way that I have found to store structured data on iOS native apps is using sqlite(FMDB). It is simple Objective C library that wrappes around sqlite.

So, using my Tool you will receive some files – Models Classes and Model Data Access Object Classes and A Base Dao Class – that will initialize the database itself.

I have been busy during the day with the everyday stuff, but this evening I fixed a thing that the xcode was whining about. I am working on an iOS application equivalent to my Android Application “Breathe In”. Along side some app specific code I’ve implemented data caching using my tool. So, what I have found is – when you pass value parameters to an SQL query, you must provided non-optional ones.

db?.executeUpdate(“…sql query..”, values: [var1Param ?? 0 ,var2Param ?? “”])

So if your incoming variables are optional you must place some default value like this (someVariable ?? 0) or (someVariable ?? “”).

let var1 = var1Param ?? 0
let var2 = var2Param ?? “”

When the parameters get too much  the IDE is whining and you’ve got to introduce local variables.

https://tomavelev.com/GeneratorApp/

Let’s see how my Idea of writing about technical stuff goes. Good night for now.

Share
Add comment