Connecting to the ParksnPeaks server
When I first started working on ParksnPeaks, the web server was producing data in XML. I had some code that I found on the internet, massaged it to suit and that gave me the data in a “sort of usable” form. Okay, it wasn’t that usable! I could display it as a line of text on a list but breaking it up into bits such as callsign, frequency, location etc wasn’t easy.
Allen (VK3ARH) decided to upgrade the output from the webserver to JSON format which is text based and when you know what you are doing it should be easy, right??? That was a challenge! I hadn’t had the pleasure of working with JSON before. I understood the data I was getting and sometimes I could even see it in my debugger but breaking into individual bits so it could be displayed within a list on screen was much harder.
Many programmers would be looking for the substring command but I definitely didn’t want to go down that path. So I did a lot of reading and ended up with a data model. Then I used the Swift JSON Serializer to read the data and separate each field into the model. From there I plugged each bit of data from the model into labels in a cell on my list.
I decided to setup a database in MySQL, a web server using PHP so that I could mimic what Allen was producing, then I could play all day and night to my heart’s content. I also wanted to write back to the server and didn’t want to bother Allen, especially if I was up at 2am and saving lots of Spots and creating havoc on the website. I used to hate PHP but now, oh well, it does the job! I certainly wouldn’t want to change my career to PHP programmer.
Creating my own test server proved to be very successful. I inserted some Spots from his website into my database tables and fed it to the iPhone app as JSON data. In an iPhone list, you can program one cell to hold additional pieces of data. I had Andrew’s (VK3ARR) Android documentation, so I started with the way he had laid out his data. My first attempt was to do a test app to just read the data and display it in the list. It finally worked, even though the site name overwrote the Mode, I had liftoff.
You can see this is dummy data from my temporary web server.
First Spots Lists
Once I had my app running against my test server, I then hooked it up to Allen’s website and it worked first time.
Here is the first screenshot of my app using real data from ParksnPeaks.
Finally!!