Archive for the 'Cocoa' Category

Apr 26 2009

Introduction to Protocols

Published by john under Cocoa

What follows is a quick introduction to working with protocols. This is good background information to understand as protocols are common in various Cocoa frameworks. A protocol is means to define a list of required and/or optional methods that a class implements. If a class adopts a protocol, it must implement all required methods in the protocols it adopts.

Cocoa uses protocols to support interprocess communication through Objective-C messages. In addition, since Objective-C does not support multiple inheritance, you can achieve similar functionality with protocols, as a class can adopt more than one protocol.
Continue reading...

No responses yet

Apr 14 2009

Basics of Notifications

Published by john under Cocoa

What follows is a brief guide to working with Notifications in Cocoa. I’ll cover the basics, including registering an observer and posting notifications, just enough to start using notifications in your apps.

There is an instance of NSNotificationCenter available to every running application. This class acts as an intermediary to facilitate communication between objects that are interested in being notified at some point in the future (these objects are known as the observers) and a poster that posts to the notification center, resulting in all observers (registered for a specific notification) being called.
Continue reading...

No responses yet

Jan 16 2009

Date Formatters - Part 3

Published by john under Cocoa

While working on an iPhone application recently, I needed to convert a date read from an XML stream that was in the following format: 20081122 to a nicely formatted string for display on the device: Saturday November 22, 2008.
Continue reading...

No responses yet

Jan 09 2009

Date Formatters - Part 2

Published by john under Cocoa

In the first post on working with dates several of the examples use the “old style” date format syntax. The examples work, however, I want to show an additional example that uses the ICU (International Components for Unicode) library for format strings.
Continue reading...

No responses yet

Dec 30 2008

Date Formatters - Part 1

Published by john under Cocoa

Sometimes all you’re really looking for is a basic chunk of code to get something done. For example, I was working on an application yesterday and needed to display the current date in text format: October 29, 2008. A simple concept for sure, however, with the many nuances of date formatters, it takes some time to pull together the “right” code.
Continue reading...

One response so far

Sep 12 2008

Minnesota CocoaHeads Recap

Published by john under Cocoa

The Minnesota CocoaHeads met tonight and it was an interesting spin on development for the Mac. Troy Gaul did a presentation on Adobe Lightroom, from the perspective of the development tools and approach used to create Lightroom.

Although I have heard of Lua , I had no idea of the depth of its usefulness. It was impressive to see the extent it’s used in Lightroom, somewhere in the neighborhood of 60% of the code base. Continue reading...

Technorati Tags:

No responses yet

Aug 20 2008

Filename and Line Number with NSLog: Part II

Published by john under Cocoa

In the previous post (on the iPhone Developer Tips blog) I demonstrated a simple debug class that I wrote to wrap some additional code around NSLog. The code allows for displaying additional information beyond the date/time stamp and process ID that NSLog outputs, specifically, the filename which calls the debug routine, and the line number where the call was invoked. I also added a few additional configuration options including an option to disable all debug messages.

You can read the rest of the tip on the iPhone Developer Tips blog.

No responses yet

Next »