Step Up Your Art With New E-Traces Dance Shoes

As technology is accepted more and more into our daily lives, the effect it can have on one of our most elemental fascinations - artwork - becomes increasingly intriguing.  Now, thanks to one company's innovative new ballet shoes, the worlds of dance and abstract visual art have got a new way to tango. 

Like shoe-shaped Sharpies for your feet.
(Image courtesy cargocollective.com.)

According to makezine.com, designer Lesia Trubat Gonzalez's new project, E-traces, follows your footwork and turns it into artwork.  A Lilypad Arduino-based sensor takes pressure data from a dancer's feet, sending data from the customized ballet shoes to a computer program.  This then transforms the various movements into brushstroke-esque imagery.  The app allows customization and even graph readout of the data.

The technological palette.
(Image courtesy cargocollective.com.)

The technology could be used to assess one's performance (particularly in comparison to other dancers' graphical results) as well as to create a new form of visual art.  Can calligraphy be choreographed?  Dance a mile in these shoes and see what strokes of artistic genius appear.

Don't just wait for the dancefloor to change colors as your boogie!  Use E-Traces to add to the art!
(Image courtesy 2.bp.blogspot.com.)


Networking in Swift: Building the Swift Client, Part 3

This is part three in the tutorial segment on building a Swift client application to query a RESTful web API, from our series of articles on networking in Swift. In the first segment, we created a custom RESTful API in PHP that serves up the inventory of our hypothetical plumbing supply shop.

In this segment, we have been building a Swift client which queries this API and delivers that inventory content to our end user. In part one, we got our Swift application up and running. In part two of building the Swift client, we created our basic data model, hooked up the segues to our inventory views, and successfully handled raw responses from the server by printing them to the Xcode console.

In the present article, we'll create model objects from the JSON dictionary returned by the server (at the end of part two), and display our inventory item lists in their respective table view controllers.

Model Objects
When we left off in part two, we were filling out the requestInventory method in our PlumbingSupplyInventoryTableViewController. Currently, that method simply prints the returned JSON dictionary to the Xcode console. We'll now create model objects from this dictionary by factoring out the relevant code from the requestInventory method and placing them in a separate method to handle this logic. In your PlumbingSupplyInventoryTableViewController file, add the following method below the requestInventory function that we were working on in the previous article:

Notice that in the last line we do not print out the jsonResult dictionary object but instead wrap it in an array and return it to the caller. In the requestInventory method, replace the three lines of code we factored out into the new inventoryItems method with the following two lines of code:

If you run the app and select one of the two inventory item categories, you should see the same response as before in your console, but wrapped in an array. We'll now refine the raw JSON data. Replace the return [jsonResult] line of code in the inventoryItems method with the following snippet:


Let's take a closer look at this. The first line gets the raw data dictionary object from the JSON results container. The second line defines a container that will hold model objects that are built from the raw data dictionary objects from line one. Inside the for loop we iterate through the raw data dictionary objects and build an array of refined data objects. And in our last line we simply return the array of model objects.

If you now run the app again, you'll see the difference in the Xcode console output, which now returns a tidy array mapping individual inventory items to their memory locations. Let's display these inventory lists in their respective views.

Displaying Our Inventory Item List
Return to the main storyboard. Locate and select one of the table view cells from our PlumbingSupplyInventoryTableViewController scene. In the Attributes Inspector, locate the Style drop down menu and select the option “Basic.” Locate the Identifier field and type in “Cell”. Finally, locate the Accessory drop down menu and select the option “Disclosure Indicator.” Do the same for the other cell as well.

Now open the file PlumbingSupplyInventoryTableViewController.swift file. Inside and toward the top of the class, add the following property:

This data source property will supply our dynamic table view cells with the information to display on screen. The number of items in our data source will always be equal to the number of items from a single plumbing supply inventory category. In the same class  replace the default boilerplate code for the three methods below with the following snippets:

These data source methods are called by the system to query this controller on how to proceed when building our table view and displaying content within it. In the first method we simply tell the system that our table view will display only one section. The second method says that the number of items in our single table view section is equal to the number of items in our data source.

The last method does several things to build a table view cell. In the first line (line 12 in the snippet above) it dequeues a reusable cell. When scrolling a table view, table view cells that scroll off the screen are placed on a queue for reuse and cells that scroll onto the screen are removed from this queue and reused. This process helps speed up table view performance which makes possible the smooth table view scrolling with which we are all familiar. On the second line (line 13) we utilize the indexPath object to get the row number of the cell that is next to become visible in our table view; the row number corresponds to a unique item in our data source. There is a one-to-one correspondence between the cells and the items in our data source. The following line gets the name of an inventory item and assigns it to the label of the next cell to become visible. The last line simply returns that cell.

Let's jump back to where we defined our requestInventory function. In this method, replace this line of code that reads println(inventoryItems) with the following snippet:

What's going on here? In line 1, we capture a reference to the data source that is received from the self.inventoryItems(data) method call. The next segment is a C level API call to a dispatch system, on a queue of our choice, which executes code that we place inside its block/closure. The code inside the closure performs updates to our UI elements.

According to Apple's documentation, any code that updates UI elements must be executed on the main queue—which is what we do. The first line within the closure asks our table view to reload since we have assigned items to its data source. The second line hides the web activity indicator spinner, since our request for web content has terminated. Run the app and select on of the two plumbing supply categories. Once the content downloads you should see a table view similar to the one depicted below:


Success! We've successfully displayed the list of inventory items returned by the web API. Notice, however, that we did not use the callback responseHandler( error: nil, items: nil) closure but instead updated our UI in the method from above. We leave this as an exercise for the reader to implement. If you are not sure how to go about implementing this, don't worry, we wrote another method on a different controller that uses the closure to update its UI elements after an update. We do this towards the end of this tutorial.

This project can be found on GitHub.

We're almost done! In the next article, we'll display thumbnail images alongside each of the items in our inventory list above. And then in the final tutorial, we'll build our item description scene for each item in the inventory that displays the full image along with the extended description supplied by our API.

Index
Introduction
Introduction and Overview: From the Back End API to the End User Application

The Web API
Building a RESTful API in PHP, Part 1
Building a RESTful API in PHP, Part 2

The Swift Client App
Networking in Swift: Building the Swift Client, Part 1
Networking in Swift: Building the Swift Client, Part 2
Networking in Swift: Building the Swift Client, Part 3
Networking in Swift: Building the Swift Client, Part 4
Networking in Swift: Building the Swift Client, Part 5


This tutorial was authored by Stefan Agapie, a Senior iOS Software Engineer, and adapted for the present piece. 

Bitcoins And Biohacks: Dermally-Implant Your Dough?

Body modifications have been around as long as humanity.  We are constantly seeking new ways to embellish, improve, and artistically distinguish ourselves by pimping our corporeal rides, and now, technological innovations may be added to that mix.

As reported by the Telegraph UK, Dutchman Martijn Wismeijer has had 12mm NFC (near-field communication) computer chips embedded in his hands as a sort of human upgrade. On these chips, he stores the keys to his bitcoin wallet, as well as a personalized alarm clock where the chips must be held to a sensor to shut off his daily alarm.  

Easier than carrying around a sack of doubloons, for sure...but not as secure.
(Image courtesy techinasia.com.)

The 888-byte chips were installed via a ready-made syringe which delivered them to the fatty subdermal flesh.  While Wismeijer admitted that many doctors were recalcitrant to perform the modification, other body artists such as tattooists or piercers may be more amenable (although regardless of the surgeon, sterile conditions are still a must.)

The founder of Mr. Bitcoin, a company that deals in crypto-currency ATMs, Wismeijer says the chips are not secure enough to permanently carry the codes at the moment, but that his experiment in embedding them was a success.  He eventually would like the technology to include wireless key access for his home.  Wismeijer feels this type of "bio-hacking" is just the fingertip of the bigger body of possible uses for the technology.

In the beginning, there was the byte.
(Image courtesy storiesbywilliams.com.)

Wismeijer explained, “The reason I did take the implants is that I have real-world uses for it today, my phones and tablets are all compatible. I personally feel that by supporting these bio-hacking developments we can learn what works and what doesn't and that some day, in the not so distant future we will be able to implant more functionality like sub dermal glucose sensors or heart rate monitors and other vital health monitoring devices. Imagine a normally invisible tattoo on your arm glowing red when you get a heart attack, swipe your phone and your phone will notify doctor.

“By supporting these bio-hacking initiatives I believe we are paving the way for social acceptance while at the same time we support the bio-hacking technology that drives it.”

Bodymodding biohackers, use your new powers for good.
(Image courtesy hackpittsburgh.com,)

Roaches To The Rescue! New "Biobots" Could Help Respond To Your Cries For Help

Technology can be used for all manner of rescues.  We have devices and programs that can spot and stop fires, find humans in the dark, preserve habitability in difficult environments, and much more.  But what about sending another species on a rescue mission, amped up with the benefits of technology?  Meet the biobots.

As reported by the Atlantic, biobots are basically hot-rodded common cockroaches.  Armed with small electronic "backpacks", they are able to transmit sound wirelessly using a multi-directional microphone.  These dispatches are analyzed by first responders and could be used to help determine everything from a leak in a pipe to a human trapped under a pile of collapsed debris.

Is this the real hero Gotham needs?
(Image courtesy hightech-edge.com.)

Dr. Alper Bozkurt, an assistant professor of electrical and computer engineering at North Carolina State University and major contributor to the project, explained, "In a collapsed building, sound is the best way to find survivors."

Another type of the "backpack" the roaches can be outfitted with uses three-directional microphones to locate the source of the sound, which hopefully the roaches can be trained to pursue.  The research team hopes to train the roaches to go for only the most important sounds, such as prioritizing human cries for help rather than lesser distractions.  In time, these public nuisances may be recreated as creepy, crawly heroes!

Then it's only a matter of time before they teach themselves to remix the sounds into funky Roachstep jams.
(Image courtesy ddppchicago.files.wordpress.com.)


Space Station Sunday: Back To Earth For Expedition 40/41


Astronaut Gerst's (L) "favorite space selfie."  Great work, Expedition 40/41!
(Image courtesy NASA.gov.)

Good evening, space fans!  The upcoming week will be bringing some changes to the ISS.  Most notably, the three crew of Expedition 40/41 - NASA astronaut Reid Wiseman, ESA astronaut Alexander Gerst, and Russian cosmonaut Maxim Suraev -  will be returning to Earth this evening in a Soyuz TMA-13M spacecraft that had been docked on the station.

Astronaut Gerst's captivating and entertaining space photos will be missed.
(Image courtesy NASA.gov.) 

The perpetually-enthusiastic Gerst - who claims he will miss doing backflips while he brushes his teeth, but is excited to be able to soon run in forests again - posted the above image to his social media outlets today.  The image was captioned, "Thanks to all of you for flying to space with me, it's been a blast. I am glad we did this together!" So are we, @Astro_Alex.  Danke.

Astronaut Wiseman documented some of his final time on the mission with a fly-through video of the ISS, showcasing the tight quarters but fun floatability of life in the orbital laboratory.  Travelling at 18,000 miles an hour is a whole new kind of life in the fast lane, but the astronauts' cheerful spirits and dedication to progress shine through in their work.



The entire crew also took an official group photo to commemorate their successful mission.  Congratulations, crew!
Fancy dress on the ISS (pants striped with velcro for keeping floaty items close by are a must for ISS fashion.)
(Image courtesy NASA.gov.)


The Soyuz spacecraft was tested by the returning astronauts during the week to make certain there were no leaks or other problems. Their spacesuits underwent similar assessment and were found to be in fine condition. Aside from the likelihood of snow in their Kazahkstan landing zone, the astronauts should have a safe flight home. 

During their time on the ISS, the Expedition 40/41 crew had conducted an array of research, ranging from combustion experiments to diverse biological analysis to sticking a GoPro in a giant floating ball of water (as seen below.)



The astronauts' progress, as reported by the Orlando Sentinel, has been positive so far, and they are slated to be back on-planet around 11 p.m. EST.  The reentry process, according to the ESA, will be exciting:  "Their bumpy ride begins as they hit the atmosphere and they jettison parts of their spacecraft. Parachutes will deploy and retrorockets will fire an instant before touchdown to slow them down for a dramatic but safe landing."

Welcome back to gravity, spacemen!  Soon, a new multinational three-astronaut team will head on up to join the three remaining ISS astronauts (American Butch Wilmore and Russians Alexander Samokutyaev and Yelena Serova.)  We can't wait to see what happens next...watch this space!

Cosmonaut Max Suraev doesn't look like he wants to go home yet.
(Image courtesy NASA.gov.)


















Networking in Swift: Building the Swift Client, Part 2

In the first part of this tutorial segment on networking in Swift, we got our client app up and running with a simple table view controller listing the two inventories supplied by the RESTful API we created in the initial segment of the series. In the present article, we will: 1) set up our data model, 2) create the segues to our inventory views, and 3) process raw responses from the server asynchronously. 

Building the Item Data Model
Our code looks better and becomes easier to manage when we build objects that represent or model the data items that we receive from our web service. To this end, we'll create a file for our individual plumbing supply items using a Cocoa Touch Class template, and then fill it out with the necessary parameters supplied by the API. Open up your Xcode project if you haven't already. In the Xcode Project Navigator panel, right click on the top most group folder. From the menu options that appear, select new file.



You will be presented with a set of options similar to this:


Under iOS, select Source, followed by Cocoa Touch Class, then click Next. Under the secondary menu options: next to the 'Class' field type in PlumbingSupplyItem. For the next field, 'Subclass of', type NSObject, do not create a XIB file (uncheck box), and for the Language portion ensure that Swift is selected:


Click 'Next'. When prompted to select a destination, place the file alongside the other project files. If the file is not automatically loaded into Xcode, then open it from the Project Navigator panel. Now place the following code within the PlumbingSupplyItem class implementation:

As you can see, this code block models the data item passed from the RESTful API we built in the previous segment of this tutorial series, initializing an item id, an item name, an associated image and an item description. It doesn't get much simpler than this.

Segues to the Inventory
With our data model in place, we'll now create our controller class for our inventory, using a table view. This will allow us to mediate between the two inventory table views upon a touch event by the end user.

In the same manner that we created the PlumbingSupplyItem model file, create a new file named PlumbingSupplyInventoryTableViewController using a Cocoa Touch template, and have this file subclass a UITableViewController. From the Object Library, located in the Utilities panel, drag and drop two UITableViewControllers into the main storyboard as depicted below:

Select one of the two view controllers that were just dropped in. Now, in the Identity Inspector, located in the Utilities panel, find the Class field, and type in the name of the class we just created (i.e. PlumbingSupplyInventoryTableViewController) as shown below:

Do the same for the other controller as well, since we are building two separate views of the same kind of object, i.e. items in each of our two inventories.

Note that when you are zoomed out in a storyboard, you can only make selections on the view controllers themselves. To make selections on a controller's internal elements, you have to zoom in. Armed with that information, go ahead and select the cell with the label 'Plumbing Tools'. While holding down the Control key and the left mouse button, drag your mouse over to the top right most view controller and release. During this motion you should see a blue line stretch from our starting location, the table view cell, to our final destination, the view controller.


Upon releasing your mouse button over the controller, a menu will appear. Select the top option that reads: Selection Segue->Show.


Now repeat the same steps for the other cell as well. Your storyboard should look like the following:

What did we just accomplished? We have set up view controller view transition objects known as segues. These segues will respond to a user's touch of a cell. When a cell is pressed, the associated segue will transition to the view controller that it points to.

Preparing Our Segue
Since we will be using a single view controller to display the different inventories of plumbing supplies from the two possible options, namely, Plumbing Tools and Copper Pipes and Fittings, we need to inform the destination view controller which cell was selected. The tip of a segue arrow is said to point to the destination view controller and the tail of the arrow is said to originate from the source view controller. Create a file named PlumbingSupplyCategoriesTableViewController and have this file subclass a UITableViewController.

Now we'll hook it up on the story board. Select the source view controller, i.e. the controller with the two cells. In the Identity Inspector, located in the Utilities panel, where the field reads 'Class', type in the name of the file and class we just created: PlumbingSupplyCategoriesTableViewController. In the main storyboard, select the segue arrow that is associated with the cell labeled 'Plumbing Tools'. From the Attributes Inspector, located under the Utilities panel, locate the Identifier field and type in: plumbingTools.

Do the same for the other segue arrow, but this time provide the Identifier with the name from the title of the other inventory list: copperPipesAndFittings.

We're now going to jump back to our code files. In the PlumbingSupplyInventoryTableViewController.swift file, place the following code (in line 3 below) immediately after the class definition, like so:

Now, over in the PlumbingSupplyCategoriesTableViewController.swift file, replace all the code inside the class PlumbingSupplyCategoriesTableViewController: UITableViewController { . . . } with the following snippet:


This is a system call method that is responsible for notifying the source view controller that a segue is about to be performed. The title that we set in the code above is to the destination table view controller that we segue to. On this destination controller we also set the plumbing inventory url endpoint so that the controller can load the content that was chosen by its corresponding table view cell. Our destination has enough information to load the entire inventory of the selected plumbing category.

Holding Pattern: Activity Indicator
Before we request a list of inventory items, it is customary to run an activity indicator to show the user that our app is in the process of getting some information to display. In the PlumbingSupplyInventoryTableViewController.swift file, below the line of code that reads var inventoryUrlEndpoint : String = "", enter the following line of code:

This line of code creates an instance of UIActivityIndicatorView and makes it private. Now we're going to fill it out inside the viewDidLoad method. In the same file, but inside the method override func viewDidLoad(), add the following lines:


Save all your files and run the application. Once it loads, segue to the two inventory table view controllers. You should see an activity indicator animation as shown here:

Requesting an Inventory
Inside the PlumbingSupplyInventoryTableViewController.swift file, immediately below the webActivityIndicator property, we'll now define another variable that holds a reference to a URL session object that will asynchronously handle our web request. Enter the following line there:
var urlSession = NSURLSession.sharedSession()
At the bottom of the same class, we now define a function that will perform the url session request, parse the request and send us back objects if the success was successful. Here's our first stab:

If you are new to Swift, this function might look rather cryptic. That's because it is! It was no easy task to get this right—a whole lot of Google engineering was required on our end. Lets break it down by parameter:

    'endPointURL : String'
        - 'endPointURL' is an arbitrarily chosen parameter name that we defined in order to identify this parameter, and the 'String' portion requires that the passed in object be of string type.

    'responseHandler'
        - 'responseHandler' is an arbitrarily chosen name for our closure, a.k.a block in Objective-C.

    'error : NSError?, items : Array<PlumbingSuppleyItem>?) → ()'
        - This portion defines a closure.
        - The 'error : NSError?' segment is again an arbitrarily chosen parameter name, and the 'NSError' portion requires that the passed in item be of NSError type.
        - The question mark (?) indicates that the passed in object is optional, meaning that a nil may be provided—in its absence we are required to pass in a none nil value NSError object.
        - 'items : Array<PlumbingSupplyItems>' indicates that the passed in object is a container that holds objects of PlumbingSupplyItem type. 
        - The arrow followed by the parenthesis '→ ()' indicates that this closure returns no values. Instead, objects are passed through the closure's callback parameters.
        - The second arrow followed by parenthesis '→ ()' indicates that the function returns no values.
        - The arrow along with the parenthesis may be omitted for both the function and closure.

Okay, that was a mouthful, but what happens when the view appears on the screen? Let's define it. Right below the viewDidLoad method, we add the following code for our new viewDidAppear method:

This function will be called by the system when the view appears onto the screen. This is good spot to begin requesting inventory items. Notice that we are calling our previously defined requestInventory function. Let's revisit that function now. Replace all the existing code inside the requestInventory method implementation, with the following snippet:


Let's go through this line by line. Line 1 creates an NSURL object from the provided endPointURL string that is referenced by a constant named url; it is essentially a wrapper object for a string formatted URL. This NSURL object is required by our urlSession object that is on the next line of code.

On this line of code, i.e. line 2, we create what is known as a 'data task' for querying our web service. This call spawns an asynchronous operation that communicates with our PHP web service without blocking the main thread. Not blocking the main thread is highly desired if we want our user interface to continue to be responsive—this makes for a better end user experience. Once the communication with our web service completes, the completionHandler closure and all of our code that is contained within this closure is executed. The closure has three parameters: 1) the raw data that comes from our web service, 2) a response object containing the headers from our web service response, or 3) an error object if the request failed.

Line 4 prints the response object inside the Xcode console.

Line 6 is a call to a closure that we defined for our requestInventory function. The parameters provided are an error object if any, and a list of data objects for our inventory items. Currently, we only return nil values. 

Run the application the select both Plumbing Tools and Copper Pipes and Fittings table view cells. You should see the response objects printed for both selections in your Xcode console. The responses in your Xcode console should look similar to this:


Success! Notice that the response object is of type NSHTTPURLResponse. This response object contains information about the requesting url, and the header fields from our web services. Notice the status code of 200; this means that request was completed without issue. You can also print the data object but in its raw form it will not make much sense—try it if you'd like. The communiqué between the host and client is comprised of two parts. The first part is known as the head or header and the second part is known as the body. A typical request or response will contain both of these parts (It's possible to just request the head of a web service response—Google to find out how). The real-world analogy that is often used to describe this is paper mail. The electricity bill, for example, is comprised of two parts as well. The first part is the envelope itself that contains information about its sender—the head. The second part is the contents of the envelope that contains information for the recipient—the body.

JSON Parsing
Now let's get our raw inventory. To do this, we take the response or body of the message and translate it into a container that we can readily read from. In the same function that we've been working on, replace the following line of code that prints out the response, (i.e. println(response), line 4 in the snippet above) with the following:

The first line of code creates a parse error pointer to an object of type NSError, or nil value. On line 2, we call the NSJSONSerialization class method JSONObjectWithData(. . .) and pass to it our raw data response from our web service along with the memory address of the pointer that we created on the first line.

This last method will convert our raw data into a mutable container of type NSDictionary. If the conversion process fails, then this method will assign an error object to the provided memory address with a description or nature of the failure.

The last line of code simply prints our newly created container to the console screen. Save the file then build and run the application. Navigate to one of the inventory endpoints from the table view. In the Xcode console, you should see a similar response to this:


This project can be found on GitHub.

Success! Our application is now querying our tools and supplies API, and returning the inventory response for each of the categories listed on our primary view controller. In the next article in the series, we'll create model objects and then display our inventory item list in our Swift client. Continue to part three on building the Swift client.

Index
Introduction
Introduction and Overview: From the Back End API to the End User Application

The Web API
Building a RESTful API in PHP, Part 1
Building a RESTful API in PHP, Part 2

The Swift Client App
Networking in Swift: Building the Swift Client, Part 1
Networking in Swift: Building the Swift Client, Part 2
Networking in Swift: Building the Swift Client, Part 3
Networking in Swift: Building the Swift Client, Part 4
Networking in Swift: Building the Swift Client, Part 5


This tutorial was authored by Stefan Agapie, a Senior iOS Software Engineer, and adapted for the present piece. 

Become An Instant Connoisseur With "Vivino" Wine App

Want to imbibe wine like you're fancy, but have no idea where to begin?  No worries, with the new Vivino app, you'll be able to find the greatest of the grapes, using only your smartphone.

Simply upload a photo of any wine label that strikes your fancy, and you'll be able to immediately access pertinent information, reviews, ratings, and price guides.  With over 6 million users contributing feedback using a 1 to 5 star ratings scale, you can get a good feel for what's smooth sipping versus swill.

While the old-fashioned way of just trying everything also works, with Vivino there's a way to help you accurately REMEMBER your favorites.
(Image courtesy wikimedia.org.)

As reported by winderlusting.com, Vivino can also sync with your social media.  Linking with Facebook, Twitter, Google, and more, you can interact with other oenophiles who may share your same tastes.  This also enables the casual drinker to follow more seasoned sommeliers who can offer a wide variety of personal experience.

The Vivino app is free and works on all iPhone, Android, and Windows smartphones.  A $4.99 upgrade is also available for those who want to track sizeable selections for their cellar.  So whether you're a collector or just wondering about what you're housing down at happy hour, Vivino can help you perfect your palate.

Seriously, you can do better than this.
(Image courtesy iwishilikedflan.com.)