Blog Stats
  • Posts - 164
  • Articles - 0
  • Comments - 36
  • Trackbacks - 0


Wednesday, March 18, 2015

Final Polishing of Apple Watch App

Its done,  my first Apple Watch App.   Ready to send to Apple when they allow submissions….


Saturday, February 21, 2015

Cross Platform with Raspberry Pi

So this is nice.   Being able to fully access RPI file system from a Mac.  Just tweaked 

sudo nano /etc/avahi/services/afpd.service

To get hostname all looking consistent (i.e Mac and PC all see Raspberry Pi having a standard name).    So now I can edit and add new files from Mac/PC seamlessly…    


Thursday, February 19, 2015

Apple Watch - oData and Images

So its been a month since I started experimenting with making oData calls from the Apple Watch SDK.     I picked up the project again this evening.

I wanted to go beyond the basics and try and get some images out of the Northwind demo database,  and display those to my watch user.


I found that Northwind database really does date back to an original  Microsoft Access sample and all images in the database are prefixed with 78 bytes of stuff.

So this is what I did to extract the images from the Odata feed (in Swift)


func populate(ret:[NSObject : AnyObject])



        if let records=ret["Data"] as? NSArray


            var rec:NSDictionary=records.objectAtIndex(0) asNSDictionary

            var picstr = rec.objectForKey("Picture") as String


            let decodeddata = NSData(base64EncodedString: picstr, options: NSDataBase64DecodingOptions(0))!


            var range:NSRange = NSMakeRange(78, decodeddata.length - 78)

            var refinedData = decodeddata.subdataWithRange(range)



            var ourpic:UIImage = UIImage(data:refinedData)!



End result, images on an Apple Watch!







Wednesday, February 18, 2015

oData Offline, Worth The Wait?

So I’m syncing data to my App.   It all works well,  I’m looking at strategies now to disguise the (inevitable) synchronisation process.


At the moment, I have a nice Windows Mobile esq. form.   I’m sure I can improve on this...


IMG 2414

Wednesday, February 11, 2015

Odata Consistency

So I’m drawing to the end of a long day and a long project.    As you know I’ve been building an iPad client in Swift that uses Core Data and OData to provide offline and online access to Dynamics NAV.

A few observations - 

Odata is different depending on what you do,  criteria for a filter clause, is different to an individual clause.   You have to remember/guess what to URL escape when to use quotes/double quotes etc.

Don’t fear it.   Its powerful.   I’ve spent all my time in the front end,  not getting bogged down in adding web service methods for everything you need.

Its responsive.    If a field isn’t there or something has changed it tells you at runtime.    Add web-reference/service reference is just a million miles from this.

Its lightweight.   Everything is sent up and down in JSON format.   Speed is incredible.


Would I do it again?   Now that I have SWIFT libraries and extensions to base classes,  HELL YEAH!

Friday, February 6, 2015

SWIFT a property to set controls to visible

Fed up with typing .hidden=true ?

My brain only works with .visible = false 

Is it me, or does the World need this SWIFT extension?

Just add this in a file to your SWIFT app.


import Foundation

import UIKit


extension UIView



    var visible:Bool




             return !hidden




            hidden = !newValue




Tuesday, February 3, 2015

WatchKit and IOS shared Libary

Sunday evening,  early evening experiment.

Want to share some swift code between an iOS app and Watchkit app, simply.

I’ve tried to follow a few articles, but this worked for for me.

First up,  just right click your project, and add “New Project…"

Select Framework and library & then follow this...




I then added a swift class (called Mega) as follows -


import Foundation


public class Mega
    public func Rock()




So then, I scrolled to project explorer, and added my framework to my watchkit app - 




So all going well, I then did this in my WatchKit app.


import Brilliant


class MapController: WKInterfaceController


    @IBOutlet weak var ourmap: WKInterfaceMap!



    override func willActivate() {

        // This method is called when watch view controller is about to be visible to user



        var m = Mega()






Then I got the output 




A little complex, but this has great potential to share code and build libraries...

Sunday, January 18, 2015

Apple Watch - DOES oData


This is cool!   I just got an Apple Watch App.  getting results live over the Internet from an oData database.   All realtime, and working really quickly.   Here’s how it works….

So using the following code in an Apple Watch app.

WKInterfaceController.openParentApplication(ourmsg, reply: { (replyValues, error) -> Void in dispatch_async(dispatch_get_main_queue(), { self.populate(replyValues) });

This makes a call into my iPhone app. which makes an oData request.

The results then come back and populate a table using a callback to main thread.

The iPhone app, has a very simple bit of code that responds to the watch request and looks like -

func application(application: UIApplication!, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!, reply: (([NSObject : AnyObject]!) -> Void)!) {
var xx = Core().oDataQuery("Categories")
xx.invoke { (ret, error,status) -> () in
if error == nil
if var returndata:NSArray = ret
var ourreply=["Data":returndata]

Final bit of code, is the stuff to populate the Apple Watch table
func populate(ret:[NSObject : AnyObject])

if let records=ret["Data"] as? NSArray

self.tvourdata.setNumberOfRows(records.count, withRowType: "default")
// Iterate over the rows and set the label for each one.
for var i = 0; i < records.count; i++
// Get the to-do item data.
if let record = records[i] as? NSDictionary

if let row = tvourdata.rowControllerAtIndex(i) as? OurRowController
var label=record.valueForKey("CategoryName") as String row.lblname.setText(label)


Friday, January 16, 2015

UK Top 40 in JSON format

Wednesday, January 14, 2015

Offline & Online, so easy with oData

So today, I had to bite the bullet and realise that certain modules in my app. will only work online. Online and connected, able to see a server.... This meant I had to move away from pulling oData good stuff away from Core Data and just deal with the data that arrived by making a URL request. So this is interesting, first this feels slow. I had to put up iOS views with spinners... (never good). With offline, you can just presume stuff is there. Secondly you have to marshall data types on the fly. Bringing stuff in via core data, means you validate a date is a date, and a bool is a bool. So I'm getting there a couple of forms built and all appears to be working. I've had to build cliche little 'we could not get data from the server messages', but apart from that all good. Working with Swift feels that this is an alien world too. We're getting there....


Copyright © Richard Jones