Dec 06

Well, it took me a bit longer than expected. After multiple iterations, I settled on the UI for Celery. It took awhile to build the Nutrition Label and make it look the same as you’d see on packaging, but I’m happy with the results.

Next, I will be working with Core Data for the first time to start storing the servings eaten, and store history.

CeleryScreenSnapz002

Tagged with:
Nov 08

Once I started obtaining data from FatSecret via MPOAuthConnect (see previous posts), I had a large JSON string to deal with. I did a quick Google search for a JSON library for Cocoa. I came across json-framework, which is a very simple library. It attaches a Category to NSString to provide a method called JSONValue. Calling JSONValue returns either NSDictionary or NSArray. Yet, another beauty of the langugage, Categories allow you to extend the functionality of an existing Object at runtime.

Once, I called JSONValue on the JSON string, I was able to obtain all the values needed to display the nutritional information for a particular food, and display a list of foods on a search query. This was particularly easy, and a great library.

Tagged with:
Nov 07

The first task I gave myself with Celery is complete. I can now search for a food, obtain a list of foods that match my search criteria, select one and get more information. This little task allowed me to learn a significant amount including:

  • Using oauth and a Cocoa library to communicate
  • How to build and add third party frameworks to Xcode
  • How to parse JSON using a Cocoa library
  • Creation and usage of Protocols
  • Usage of the NSTableView class.

The first two points have been mentioned previously. I will go into more detail about the last three in future posts.

Here is a screenshot of the application.

CeleryScreenSnapz001

As you can see it is quite ugly and utilitarian. This of course is not how I plan to make the app, but just needed something to learn from. One of the beauties of using MVC, which Cocoa is really built around, I can yank the View (V) and replace it with almost no code change. Just hook up the outlets to the new UI in Interface Builder and it will continue to work as before… beautiful.

Tagged with:
Nov 01

The first task I gave myself when writing the Celery Application is to obtain nutritional information for various foods. I’ll need to provide a means to request a list of food that matches a search query and a way of getting more information about a particular food from that list. As I mentioned before, I found the FatSecret REST API, and decided to use this for these two requests. FatSecret supports “foods.search” and “food.get” methods that meet my needs. FatSecret also uses oauth for authentication.

My list of tasks were as follows:

  1. Obtain the necessary keys to communicate with FatSecret.
  2. Find a Cocoa Library to use oauth.
  3. Establish a connection and call methods as needed.

1. Obtain the necessary keys to communicate with FatSecret. This was easy enough, simply went to this site and registered the application I was making. This provided me with a Public Consumer Key and the applications Private Key. These keys were emailed to me, and they were ready to be used.

2. Find a Cocoa Library to use oauth. As I mentioned in a previous post, I found MPOauthConnection for establishing an oauth connection and calling methods on a REST Library. I downloaded the source using Subversion and opened the library. After running the Build, Xcode proceeded to lock up completely. All I got was the Beachball of Death. I stared at it, tried a couple more times, but could not successfully build the project. After awhile, I noticed that it was failing to proceed past the Unit Tests. I figured, I’m not modifying the Library, and therefore, don’t really need to run the Unit Tests. So, I opened up the Unit Test target and deleted it. Kicked off the Build and it succeeded.

I was going to start up the Celery project, but decided to go ahead and modify the existing test application to communicate with FatSecret.

3. Establish a connection and call methods as needed. The first thing that I had to do was match up what MPOAuthConnection expects to what FatSecret API expects, including slightly different nomenclature. I started by plugging in the values for the Base Host URL, Shared Secret and Consumer Key and the method to call. The method to call stumped me a bit, as the FatSecret sets the actual method to a parameter (method=VALUE). Where the method for the API is server.api. That really took me awhile to figure out. Secondly, the provided example had no usage of method parameters (making it a very flawed example, in my opinion). I struggled then to figure out the API to pass parameters, finding a Unit Test in code, I was able to figure this out and successfully make calls to the API, searching for a food, and getting information for that food.

The next step will be to build my own Celery project and duplicate this functionality in what will become my own Application.


Tagged with:
Oct 25

For a long time, I’ve been wanting to start a side project. Typically, this desire has led to Game ideas that never really got anywhere. So, I needed something that had an aspect that would drive me forward. Watching my wife go through her nightly routine of counting her calories, analyzing her meals for the day and her exercise/workout routine, it dawned on me. I started googling for Nutrition apps for monitoring these things and found that there weren’t a whole lot, and what was there was not terribly clean and a simpler way was needed. So, that is my goal. Write an app for my wife to keep track of her calorie intake and allow for advanced analysis when desired, but keeping the interface clean, simple and easy to use. Think Mint for Nutrition.

Additionally, I really want to write an application for the Mac OS X platform. I’ve been on a Mac for two years now, and really have enjoyed it. I’ve decided that it is something that I’ve wanted to delve into, and have lately been playing with iPhone development. With the introduction of Snow Leopard there are a number of technologies that I really want to look at that are not on the iPhone. Primarily, Grand Central Dispatch. Therefore, I made the decision to write this nutritional app for OS X and probably extend it with an iPhone App in the future.

So, her is the first public announcement of Celery. The Nutrition application for everyone. (I found it’s best to announce before a line of code has been written).

The requirements for Celery are few:

  • Make use of a solid Web API for obtaining Nutritional Information.
  • Create a clean and elegant UI for inputting daily values.
  • Provide a mechanism to graph historical data in an attractive manner.
  • Make something my wife wants to use.

I will be chronicling the development of Celery here, until completion or I quit in defeat (a public defeat will be bitter).

Tagged with:
preload preload preload