Showing posts with label cocoa. Show all posts
Showing posts with label cocoa. Show all posts

Sunday, April 13, 2008

Objective-C

I came across an interesting article today called "Inside the Objective-C Runtime" (see also part two). This article does a decent job explaining some of the benefits of Objective-C with Cocoa programming on OS X as compared with other object oriented languages. The article is a little dated (six years old), but most of the information is still relevant.

This led to a search for more articles touting the benefits of Objective-C. In "Objective-C: Dynamite!," the author begins with a relevant quote which should resonate with most Objective-C programmers:

"Objective-C is the result of adding object facilities to C with the goal of making programmers more productive. The result differs greatly from C++, which adds objects to C without making computers less efficient: quite a different goal." [PC Week, November 3, 1997]

Later on, for the humorously inclined:

"If a person on the street asks you for a flump, and you don't know how to respond, do you exit with a core dump?"

Sunday, April 6, 2008

Techno Speak

"When the client process sends a message to the NSDistantObject object, the proxy captures the Objective-C message in the form of an NSInvocation object and forwards it to its NSConnection object. The NSConnection object encodes the NSInvocation into an NSPortMessage object, using an NSPortCoder object, and passes it to an NSPort object connected to an NSPort object in the server process. The client’s port sends the encoded data to the server’s port which decodes the data back into an NSPortMessage object. The port message is then sent to the NSConnection object which converts it into an NSInvocation object, using an NSPortCoder object. The invocation is finally dispatched as an Objective-C message sent to the vended object. Any return value from the object is passed back through the connection and returned transparently to the client process."

Yikes, that's really something, isn't it?

http://developer.apple.com/documentation/Cocoa/Conceptual/DistrObjects/index.html

Tuesday, February 5, 2008

Localizing Cocoa Software

Localizing software (the process of translating it to multiple languages) is an amazingly time intensive process.  Apple's bundle layout, bundle loading, and localizable strings files are all very helpful, but amazingly, things always manage to find a way to go south.  Today, for example, I switched all of the localized .lproj directories to use the ISO 639-1 two letter naming conventions.  Instead of the older "English," "French," and "Spanish," I now have "en," "fr," and "es."  Great, right?  Well, not quite.  Turns out I forgot to change the CFBundleDevelopmentRegion tag in the info.plist to "en" instead of "English," so any time a localization for a language was incomplete, the nibs failed to load or the localized strings files were ignored.  Oops.  You get the idea.  ;-)
Consider the process for localizing a single nib file (which a product like TubeTV contains about ten of).
1.  Look up command line options for "ibtool" since it's impossible to remember them exactly between run times.
2.  Run "ibtool" to extract the localizable strings from the nib.
2. (a) Optionally, delete about 90% of the strings ibtool extracts since they don't really need to be translated and make the translator's job more difficult.  Sorry to the current translators for TubeTV as I didn't realize this until after I sent you the files!  ;-)
3.  Submit files to people around the world (in different time zones) who have agreed to translate them for you.
4.  Wait for files to come back, look for portions which may have been missed, go back to step 3 if necessary.
5.  Look up different command line options for ibtool to import the translated strings into a new nib file making use of the English nib as a basis.
5. (a) If parse errors occur in the strings file (which they often do is the localizers missed a semicolon or quote), use the plutil command line tool to find them.  Correct and move back to step 5.
6.  Correct sizing on controls and GUI elements in the nib since translations are often longer than English.  This can be very time consuming depending on the layout and must be done every time you update anything.
7.  Test.
That was the procedure for one nib.  Multiply that by the number of nibs in the project, and additionally, by the nibs in any internally developed included frameworks (such as our version checking system).  Want to change anything in any of your nibs?  No problem, just change the English language nib, delete all the translated nibs, and go back to step 5!  Or you could opt to change each localized nib by hand!  Ouch.
Perhaps now you have a better understanding for why much of the freeware and shareware software for the Mac isn't localized: it's a huge time commitment and it makes creating future versions much more difficult.  It would be interesting to see if this process is easier or harder than the process on other platforms such as Windows (or Java).  Anyone who has experience with those, feel free to post something in the comments.

Wednesday, January 30, 2008

More Cocoa Goodness

Came across another nice Cocoa Blog today called Living the Life which includes some freely downloadable classes for managing preferences.  The new version of TubeTV will make use of Dave's preferences class - thanks!  It literally took less than half an hour from finding the classes on the web to having the entire thing implemented in TubeTV - one of the quickest pickup times for third party additions ever!  Normally the problem integrating other people's work is just figuring out how in the heck you're supposed to use it, but Dave made the process entirely trivial.

Tuesday, January 29, 2008

Cocoa Examples

Every once in a while, I like to actually post something related to Cocoa since the blog is called Cocoa Musings.  Today during some research, I came across a nice page of Cocoa Bindings Examples and Hints.  Anyone out there who has experienced the complexity of Cocoa Bindings would probably appreciate this page.  ;-)

Tuesday, December 11, 2007

Cocoa Delegates

I came across a couple of interesting articles about using delegates in Cocoa which may be of interest to those of you with some software design background.
The way delegation is used in Cocoa is one of my favorite aspects of programming in this environment; subclass only when really necessary.
Addendum: This article from Apple is also of interest regarding delegates.