XML Parser for iOS is now featured on Cocoa Controls !

Very recently, in one of my previous contracts, I had to develop a tool to easily convert an XML flux to a JSON structure and I made a little XML to JSON Parser library available on Github: https://github.com/Zedenem/XMLParser

 

I decided to submit this library to Cocoa Controls and, as of today, it has been reviewed, accepted and made available here: https://www.cocoacontrols.com/controls/xmlparser

It is the second of my libraries to be made available on this really select iOS Controls site ! The first one was a take at making a circular UISlider (https://www.cocoacontrols.com/controls/uicircularslider) and there is more to come.

If you wonder when to use a parser like this one, here is a summary of the context where I thought it was necessary to program it :

I was working for a client’s iOS app that was making a lot of use of REST Web Services, getting and posting JSON requests both to display datas and interact with the server. At some point, I discovered that part of the Web Services weren’t conforming to the global specification and were sending back XML data structures instead of JSON.

No one knew about it when we first conceived our app data model and the problem was that I had to use the XML structured datas the same way as I used the JSON ones (both when displaying it and when posting requests to the server). Given the state of the project and the available time, I decided that it was better not to do specific work dealing with the XML and better try, as soon as I get it from the server, to convert it to JSON and “hide” the complexity behind a conversion parser.

That’s how the XMLParser library was born.

If you want to know more about how it is built and how the conversion is made, there is a README file inside the Git Repository: https://github.com/Zedenem/XMLParser/blob/master/README.md

Article image used from Blackbird Interactive’s website : http://blackbirdi.com/wp-content/uploads/2010/12/json-xml.jpg

Share Button

Sinoquiz 1.2 now supports iPhone 5

sinoquiz-icon

As my mission ended with my client at the end of May, I took the time to update sinoquiz in version 1.2 to add support for the iPhone 5 screen.

Sinoquiz allows you to test your knowledge in chinese characters, their pīnyīn writing and their translation with a fast and easy to take quiz.

For now, Sinoquiz is only available in french, stay tuned for the english version and the new iOS 7 redesign.

Sinoquiz Character View

Share Button

RESTful Web Services Exposition via Play 2.x framework and their access through an iOS app – Part 1/2

Introduction

This article is a two parts step-by-step tutorial on how to easily expose RESTful web services using Play 2.x Framework and consume them in an iOS app using AFNetworking.

In this first part, I will explain how to easily expose your apps datas in JSON format via a REST Web Service, using the Play 2.x framework.

In the second part to come, I will give you some details on how to access the web services through your iOS app.

Step by Step

Create your Play Application

I will suppose that you already have a running installation of Play 2.x framework on your machine. If you don’t, here is a link to the Play Framework documentation, which provides a great Getting Started tutorial : http://www.playframework.com/documentation/2.1.1/Home.

To create your Play Application, just run this command on your favorite folder:

$> play new helloWeb

Play will now ask you two questions:

What is the application name? [helloWeb]
>
Which template do you want to use for this new application?
	1 - Create a simple Scala application
	2 - Create a simple Java application
> 2

Just press Enter to answer the first question and type in 2 to the second to choose the Java template. Play will now say it better than me:

OK, application helloWeb is created.
Have fun!

Write your Web Service method

We are now going to write a simple method that returns a JSON result. Go to your controllers folder (./app/controllers) and open the Application.java file.

Application.java must contain its default definition which renders your index.html page:

package controllers;

import play.*;
import play.mvc.*;

import views.html.*;

public class Application extends Controller {
	public static Result index() {
		return ok(index.render("Your new application is ready."));
	}
}

We are going to add our method, calling it helloWeb(). Just add the following method below index():

public static Result helloWeb() {
	ObjectNode result = Json.newObject();

	result.put("content", "Hello Web");

	return ok(result);
}

Here are the steps taken to create this simple method:

* Create a new JSON ObjectNode called result
* Put a String object "Hello Web" for the key "content"
* Return result via the ok() method to associate it via a 200 HTTP Status Code

To make it work, we will need to add these two imports:

import org.codehaus.jackson.node.ObjectNode;
import play.libs.Json;

That’s it ! We created our Web Service method, now all we need is to expose it!

Expose your Web Service route

Last step : go to your `conf` folder (./app/conf) and open the routes file.

routes must contain its default definition which declares two routes, one for the Home page and another for all your assets:

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET / controllers.Application.index()

# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)

All we have to do now is to declare our Web Service’s route, just like this :

# Hello Web (JSON Web Service)
GET /helloWeb controllers.Application.helloWeb()

Done! You can access your newly created Web Service at its declared URL path. By default:


http://localhost:9000/helloWeb

Which should display :

{
	"content":"Hello Web"
}

Discussion

Now that you know how to expose web services, what about code organization? Where would you or do you put the WS declarations? One or several of your existing controllers? A specific one?

I would greatly like to have others opinion on this, so feel free to leave a comment.

Share Button

New App Showcase Site !

At the beginning of this week, I launched my new App Showcase website :

http://www.strikingly.com/zedenem

It’s still under construction as I am writing this post and I will had more apps in the future.

App Showcase Screenshot

As you have probably guessed, it’s powered by a wonderful tool to build promotional websites, called strikingly.

I hope you will like this showcase, feel free to give me any comments on how to improve it.

Share Button

Apple : the art of driving behaviour

golden_circle

 

 

At WWDC 2013, Apple started its keynote address with a video describing its intentions as a products manufacturer and introducing its new campaign “Designed by Apple in California”.

 

What a better example of what Simon Sinek explains at TEDxPugetSound about driving behaviour ?

“People don’t buy what you do, they buy why you do it.”

In this talk, Simon Sinek explains how great leaders inspire actions by reversing the usual chain of communication from “What we do” to “How we do it” with sometimes a hint of “Why we do it” to a Why-first communication. He calls these three levels “What, How, Why” the golden circle.

Simon Sinek takes the example of Apple’s way of selling a computer :

  • From the inside out (What – How – Why):
    • “We make great computers” – What
    • “They’re beautifully design, simple to use and user friendly” - How
    • “Wanna buy one ?”
  • From the outside in (Why – How – What):
    • “Everything we do, we believe in challenging the status quo, we believe in thinking differently” - Why
    • “The way we challenge the status quo is by making our products beautifully designed, simple to use and user friendly.” - How
    • “We just happens to make great computers.” - What
    • “Wanna buy one ?”

Sounds familiar ?

golden_circle

The Golden Circle

Share Button

iOS URL Schemes Parameters : What about standardization ?

On Saturday June 8th, I was attending the App.net hackathon in San Francisco (the article is coming soon…) and I saw a presentation about a way to standardize the parameters passed from app to app via iOS URL Schemes, called x-callback-url

If you want to learn more about this, the specification is here : http://x-callback-url.com/specifications/

And here is the associated blog where I learned, among other things, that Tumblr integrates x-callback-url : http://x-callback-url.com/blog/

You can also follow the project via Twitter : @xcallbackurl

I will certainly try to use this next time I am struggling with URL schemes, just to see if the standard is efficient and comprehensible.

What do you think about it ? Do you know other people trying to standardize inter-app communications ? Do you or would you use it ?

Share Button
This entry was posted in Blog by .

WWDC 2013

wwdc13-about-main

 

 

Apple’s WWDC 2013 takes place from June 10th to 14th at Moscone West, San Francisco.

I will be there enjoying conferences, labs, partys and meeting fellow developers and entrepreneurs.

And, well, I’m also planning on taking my sweet time…

IMG_1908

Stay in touch with me here or on the social networks for some news (that is to say, as far as the NDA doesn’t urge me to keep my mouth shut…)

Share Button

Hello world!

Welcome to the new version of Zedenem.com

Here are the new sections you will discover clicking around :

  • Blog : Where I will be able to give you quick updates on what I am doing, starting with a coverage of Apple’s WWDC 2013
  • Apps : Updates on the apps I am doing and a history of what I have done (under construction)
  • Articles : Some technical articles on various subjects I am trying to hack (under construction)
  • Hackathons : A special section to cover the hackathons I’m attending and the projects I develop during them (under construction)

Other things will be coming in the future too, stay tuned !

Please enjoy and feel free to give me feedback.

Zouhair.

Share Button