Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks

News

Welcome to the Mobile Line Of Business Blog

Tag Cloud


Archives

Image Galleries

About

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)!

            self.ourimg.setImage(ourpic)

            


End result, images on an Apple Watch!

 NewImage

 

 

 

 

      

posted on Thursday, February 19, 2015 4:47 PM