My First Cocoa Application!

What’s a Cocoa Application? You might ask.

To put it simply, its a Mac Application!

Followed Apple’s Introduction to Cocoa Application Tutorial Using Objective-C in getting started.

In the introduction chapters, it says that Cocoa programming is object oriented and makes use of the Model-View-Controller (MVC) paradigm, which is nothing new to me since the wonderful Ruby on Rails is also based on MVC.

Then off I went in creating a new Currency Converter cocoa application project in XCode2.2..

Once that was done, it was down to creating the GUI interface with Interface Builder.

Interface Builder is wonderful I tell you.

Not only can you drag and drop window components like checkboxes and textfields ala Delphi style!

window components!

it also has very very sweet alignment guides which awesomely snaps in place nicely.

alt text

Assigning Labels to have it snap in line with the TextFields is also just as sweet.

And talk about micro positioning.

Enabling TextField focus changing via tabbing is also just as easy via a control dragging and clicking some checkboxes in the Inspector. You have to try it out on your own!

Next up was to create the CurrencyController controller duh and the Currency model.

When it was time to specify how the specific Models (A Currency class which specifies data), Views (The GUI Components like TextFields) and Controllers (The CurrecyController class which is the business logic) communicate with something something new to me called Outlets, it became a little fuzzy, but you can easily accept it as some sort of message passing mechanism like MPI in Parallel Programming.

Then coding the actual controller and model classes..

After that was done… Build time!

As excitement got the better of me, I made some mistakes, but thankfully XCode was smart enough to pinpoint the exact lines with errornous code.. Great!

alt text

Finally done!!

alt text

And a raw sense of achievement ensued.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • HackerNews
  • LinkedIn
  • Reddit
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Technorati
  • Tumblr
  • Twitter

Comments are closed.