Ab Initio
This blog is going to talk about my experiences and frustrations as a software developer. A lot of what I write about is for my own personal edification and not necessarily intented for human consumption. Read at your own risk.
You can find the RSS feed here.
Busy Busy
Things have been busy around here. I've been working on many projects, some done and some still in progress.
I've been collaborating with my good friend Terry Schubring on some projects for our joint venture Jambots. We released Railroad Train for the iPad a few months ago and just got our second app, Lo-Fi Folk Arranger, into the store. We have game / toy app, Lifebulbs, that will be in the store soon as well.
These projects are all done using our awesome native wrapper. Terry creates the UI with HTML5 and WebKit goodness, while I do all the heavy lifting with objective-c. We support caching resources, so we can ship all our assets but update them when bugs come up. We created a multi-track audio engine, something web programmers can only dream of without a plugin like Flash. It also has support for iAds and In App Purchase, so we can support both ad supported and freemium models for our apps.
Check Railroad Train and Lo-Fi Folk Arranger on the app store.
Silly code snippets useful for interviews
The never ending process of interviewing with prospective employers often involves silly little logic tests. I'm going to start a series on how to solve some of these problems using standard C. These entries assume you have some basic understand of C and pointers. For the following example you should understand the basics of how C strings work.
Reverse a string for me son
To kick the series off I'm going to solve a very common problem that comes up during interviews, reversing a string. While not a practical problem, what employers are trying to determine is how efficiently you solve it.
If the interviewer does not provide you with any function prototype, then you should ask them to do so. If they tell you to make it up yourself then you have a couple of choices. I'm going to keep things simple in this post and assume that you can just pass in a character array and its length. These example do not require the use of any library functions either. Your interviewer may want you to determine the string length, either manually or using strings.h. I'm not going to talk about that for this example and just focus on the actual reversal of the string.
And then it was fall
The summer has gone by fast. I started at Thomson in July and it has been a great two months. For the first time in my career I don't worry about how long it is until Friday. Many weeks I wake up and my wife mentions the weekend and only then does it dawn on me that I don't have to work tomorrow.
I've been very busy getting a demo ready for their meeting of the board. It was pretty high profile and everyone likes what I accomplished for it. I have been mentoring a few developers on iOS development, which has been educational for myself as well.
I am presenting at CocoaHeads tonight, the topic is Core Data on iOS with Networked Apps. I put a lot of effort into it and am happy with the slides and the sample project. I'm sure that the delivery will be fine. While I don't like public speaking I have never had a problem giving technical presentations.
I have to get my secret project done soon, it will be a year at the end of the month. It has been fun at times, but now I need to get it done so I can move on. If it ends up making money great, but I have other things that require my attention and I'm certain they will turn a profit.
Summer Time
That last six months have been interesting, with many things happening.
- Updated Hansel,
- Started worked with Nibisoftware Group and got their iPhone/iPad app into the store,
- Created Contacts Map and have updated it several times with lots of great feedback,
- Continued working on NDA project for Social Networking,
- Started preliminary work on a remote control project for the Mac/iOS
This was of course outside of my regular 9-5 routine, which has recently changed. I have accepted a position as an iPad developer at Thompson-Reuters working on their next gen Westlaw application. I am very excited and this will definitely take my career to the next level.
I wish that I could have been more active on my weblog, but all of this coding has gotten in the way of that. I still want to do a series on Apache CXF/JAX-RS/iOS, and am hoping that I can get to work on that soon. As of now I just don't have the time.
iPad after a few weeks
Now that I've been working with the iPad for a few weeks, I really like what Apple has done with the development process.
Making Hybrid iPhone/iPad applications is very easy for existing iPhone apps. You simply open up the xib in IB and select the File -> Create iPad version menu option. That combined with UI_USER_INTERFACE_IDIOM() and you can reuse all your existing view controllers while having full control over how you handle specific devices.
I think there merit in making hybrid apps from existing iPhone apps in many cases. Nibipedia for instance is a perfect candidate for this. It is a small lightweight app that is mostly UIWebView driven. There isn't a lot of UI code for animations or dynamic view creation. It makes sense to just create a hybrid app.
Hansel on the other hand is more complicated. My initial attempt to make a hybrid app has failed miserably. The main problem is that I have lots of UI code that moves views around and makes assumptions about the device, that it is indeed an iPhone. While I could have written it in a more generic fashion, I never felt the need to do so. It didn't seem like there was enough benefit for spending the extra time on a free app.
Hansel Crash Reports
While submitting Hansel 1.5, I decided to snoop around iTunes Connect. I hadn't really looked at the site much recently and Apple has been busy updating it for the iPad. To my distinct amusement, I saw this message.
New Year
I started a new job over the new year. Working for ITR Group was a good experience but they lacked direction and leadership. I was the senior most engineer out of a team of 6. It was enjoyable but I'm glad it is over. I have iPhone work I'm doing on the side, so I still get my fix.
Back at McKesson, I am now working with GWT, Java, and RDF. It is interesting work and I am happy to broaden my skill set. I forgot how challenging working with Eclipse can be, but I plan to work with CXF web services to expose data to the iPhone. I'll be writing a set of articles about that in the coming months.
Projects
CarDealer
This is the fourth installment about using and accessing RESTful webservices on the iPhone.
You can download the example project artifacts here. This includes the iPhone example project and SQL Server scripts for generating the CarDealer DB and demo data.
Getting Started with iPhone + Data Services
Getting this post out took much longer than I thought. Setting up my .NET development and hosting environment was painful. My personal environment is different from my work environment, so I had some catch up after several months of not using it.
Setting up SQL Server Express was not bad at all. I had an older version and decided to upgrade it to '08. Trying to create the data services project was painless as well. The pain began when I tried deploying to IIS 6 locally. While I'm sure someone out there can do it, I was unable to make it work. I decided to setup a Windows Server '08 VM to ease the pain. It helped a lot, but was very time consuming.
I started looking around for a free .NET hosting service that I could use to make the services public for the example. After several hours a gave up on this. I could have paid for a cheap one, but I doubt that I'd ever use it for anything else.
Sample Code Update
A reader pointed out a problem with the sample code where it would not compile. I tracked down the issue in RestConnection and fixed it. The data member has been renamed to responseData. This should fix the compilation problems.
Both sample code projects have been updated with the fix.
ADO.NET Data Services
This is the third installment about using and accessing RESTful webservices on the iPhone.
There is no example project associated with this post.
Astoria
[ADO.NET] Data Services is Microsoft's way of turning EDM into web services. While researching the best way to access data stored in an SQL Server database from the iPhone, we decided to give Data Services a go around. Superficially it matched our broad criteria for the project's services layer:
- RESTful Interface,
- JSON payload support,
- Run on IIS,
- Easily access SQL Server
Accessing it on the iPhone turned out to be very simple. After it was accessible via a browser I began working on displaying a simple table from the database. I created the first version of RestConnection and I was able to get a list of data primitives out of the database and displayed in a UITableView in about an hour.
Atom is the default format for Data Services. You can specify JSON by setting the Accept header on your HTTP requests. JSON is much easier to deal with on the iPhone because of it's simpler format. However, if you have a good Atom handling methodology than that format maybe preferable.
Updates
The example code for the first 2 posts in the REST series have been updated.
I discovered a problem with the willSendRequest delegate callback not being passed the current request. There was also a bug where the Accept header was not being defaulted to application/json if one did not exist.
JSON Handling
{
"myCoolObject" :
[
"value1",
"value2"
]
}
This article will build on the previous post's project. Those classes will be modified and extended, as well as adding the BSJSONAdditions to the project. The primary focus of the changes will be on parsing the JSON data and displaying it in a UITableView.
If you have not yet downloaded the source for this example, you can do so here.
This post is not about explaining what a UITableView is or does and assumes you know how to use one. Please referring to UITableView docs for more information.
|
// Returns a dictionary representation of the last data received. @property (nonatomic, readonly) NSDictionary *dictionaryData;
...
- (NSDictionary *)dictionaryData { return [NSDictionary dictionaryWithJSONString:[self stringData]]; }
- (void)finishedReceivingData:(NSData *)data
{
NSLog(@"finishedReceivingData: %@", [restConnection stringData]);
[activityIndicator stopAnimating];
// Get the dictionary containing the raw parsed data.
NSDictionary *rawData = [restConnection dictionaryData];
// Get the interesting search results data for display to the user.
[tableData release];
tableData = [[[rawData objectForKey:@"responseData"] objectForKey:@"results"] retain];
[mainTableView reloadData];
}
A parsed dictionary representation of the data is now retrieved instead of the raw JSON. We reach into the responseData and get the results which contain the interesting information that our UI wants to display, search result information.
The table view methods section has also been added. These methods are for the table datasource and delegate implementation. Basically for each result we display a table row that shows a search result description and it's URL. Thats it, pretty simple and straight forward.
Conclusion
This post has mostly talked about JSON and how to parse it on the iPhone. The next post for the series will talk more about connecting to an EDM backed web service and some of the challenges that have to be overcome in doing so.
Until next time, enjoy.
RestConnection
I'm not necessarily a proponent of Google, however they provide some very useful web technologies that are very easy to use. For this article I'll be using their non-javascript AJAX search api. Though the RestConnection class will support all HTTP methods, I'll only be showcasing the GET functionality for now. We'll evolve the class as the articles progress.
In keeping with the classic search paradigm I'll keep the example very simple. The end result will look like screenshot on your right. The text field at the top allows search text to be entered and the text view on the bottom displays the results. You can grab the code here if you haven't already.
As will all future examples, this one assumes that you have an iPhone development environment already setup. If you don't then start here. This also assumes that you have a basic understanding of iPhone development. Some of the things I talk about may not make sense if you do not.
|
- (void)viewDidLoad {
[super viewDidLoad];
restConnection = [RestConnection new];
restConnection.baseURLString = @"http://ajax.googleapis.com/ajax/services/search/";
restConnection.delegate = self;
}
Here you can note that it instantiates a RestConnection and initializes its properties. The base URL is set which will cause subsequent requests to be relative to that URL string. The delegate is also set to the view controller's instance, this will allow it to keep tabs on the request as the it progresses.
iPhone + EDM + REST
In my first series of posts, i'm going to be talking about my experiences with developing a medical application for the iPhone. This project involved a Microsoft SQL Server database and C# .NET Entity Data Model on the backend and standard native APIs on the mobile device.
I'm going to talk about the challenges me and my coworker faced interfacing a nascent ORM with iPhone technologies. Hopefully someone else will find this information useful in the future.
The first post talks about creating a RestConnection class to facilitate gathering RESTful resources.


