5
May
2008
 

WWDC 2008 T-Shirts!

by Marcus Zarra

May 20, 2008
The T-Shirts for delivery at WWDC have been ordered. If there is enough interest I will setup a way to purchase CIMGF T-shirts (non-WWDC) directly from the site. Please contact me at marcus at cimgf dot com if this is of interest to you.


Last year I wore t-shirts for Zarra Studios and got quite a few compliments. These days I am becoming more known for this blog than anything else. Therefore, I am doing different t-shirts this year to celebrate this blog. As a reader of this blog you have an opportunity to purchase one of these shirts. They will only be run for WWDC so they are limited edition! :)

While the design is not complete yet, here is the first public draft of the T-Shirts:

Public_Draft_1.png

Normal (Male) T-Shirt

WWDC2008F_Proof_1.png

V-Neck (Female) T-Shirt

Currently, the plan is to take them with me to WWDC and hand them out to those who have purchased one right after the keynote on Monday. If you are not going to WWDC but would still like to order a T-Shirt, that is also doable but naturally shipping costs will be involved.

The price per shirt will be $20.00 US. If you are interested in purchasing one or more, please contact me at marcus at cimgf dot com and I will work out the details. Right now I am processing orders manually but if they get too crazy then I may set up an actual shopping cart. Quantities are limited so act now! ;-)

Lastly, to follow Justin’s great idea. I am interested in trading T-shirts with other WWDC attendees. If you have a NEW shirt that you would like to trade for a CIMGF shirt, please contact me at marcus at cimgf dot com to plan a swap.

All Orders must be received and paid for by the 19th of May, 2008. Any orders received after that date can be shipped but cannot be delivered to WWDC.

Legal Junk

It is not my intention to make a profit on these t-shirts. I am offering them to readers at the approximate production cost. It is not my intent to mass produce these t-shirts with the goal of making a profit. If the production run comes close to or exceeds 500,000 t-shirts (wouldn’t that be amazing!) then the artwork on the back of the t-shirts may change due to restrictions in the license agreement.

 
23
Apr
2008
 

Cocoa Tutorial: Don’t Be Lazy With NSDecimalNumber (Like Me)

by Marcus Zarra

NSDecimalNumber is Objective-C’s solution to numbers that need to be very precise. The documentation defines it as:

NSDecimalNumber, an immutable subclass of NSNumber, provides an object-oriented wrapper for doing base-10 arithmetic. An instance can represent any number that can be expressed as mantissa x 10^exponent where mantissa is a decimal integer up to 38 digits long, and exponent is an integer from –128 through 127.

NSDecimalNumber

If you are dealing with currency at all, then you should be using NSDecimalNumber. However, since it is immutable and definitely not a primitive then it is difficult to use right? Well — yes — a bit. But if you do not want to see your $9.50 item displayed as $9.49999994 or something then you are better off using NSDecimalNumber right from the beginning. Otherwise you are going to be converting to it later and that is a LOT more painful.

(more…)

 
15
Apr
2008
 

Cocoa Tutorial: Get The Most Out of Key Value Coding and Observing

by Marcus Zarra

Key Value Observing/Key Value Coding (KVO/KVC) is probably one of the most powerful and most under-utilized features of Objective-C. Here are a couple of examples of how to get the most out of it

When a call is made on an object through Key Value Coding such as [self valueForKey:@”someKey”], numerous attempts are made to resolve the call. First, the method someKey is looked for. If that is not found then the iVar someKey is looked for. If neither of those are found, then one last attempt is made before presenting an error. That last attempt is a call to the method -(id)valueForUndefinedKey:. If that method is not implemented then an NSUndefinedKeyException is raised.

valueForUndefinedKey: is designed so that when you request a value from an object using -(id)valueForKey: the object has a last chance to respond to that request before an error occurs. This has many benefits and I have included two examples of those benefits in this post–Core Data Parameters and Data Formatting.

(more…)

 
13
Apr
2008
 

Git and XCode: A git build number script

by Marcus Zarra

Git has been gaining in popularity with Cocoa developers as well as open source developers. As I work it into my development workflow, one item that was missing was the automatic injection of the build number into the application bundle.

There are a few scripts floating around that perform this trick for subversion, but git handles build numbers a bit differently and it appears that no one has bothered to publish one. As is known, subversion uses an incrementing integer for build numbers. This makes it very easy to determine which build number came first and makes it very useful for a non-public version number. Git, however, uses a hash for each build number which is not incrementing and therefore not very useful for determining version numbers. However, it is still very useful for pulling up a specific build when a crash report is received, etc.

Therefore, with the help of Matt Long’s perl-fu, I have updated Daniel Jalkut’s subversion perl script to work with git. Since the build numbers are not sequential, I would not recommend using them for Sparkle. Therefore, in my own build process for iWeb Buddy, I hand select the version number (for example 1.0.4) and then use the short hash from git as the CFBundleVersion number. Normally this number is displayed in parens after the primary build number but, at least in iWeb Buddy, I have removed it from the display entirely. Since it is no longer a sequential number it would only potentially confuse users and it displays in the crash reports anyway.

The updated script is as follows:

# Xcode auto-versioning script for Subversion by Axel Andersson
# Updated for git by Marcus S. Zarra and Matt Long

use strict;

# Get the current git commit hash and use it to set the CFBundleVersion value
my $REV = `/opt/local/bin/git show --abbrev-commit | grep "^commit"`;
my $INFO = "$ENV{BUILT_PRODUCTS_DIR}/$ENV{WRAPPER_NAME}/Contents/Info.plist";
    
my $version = $REV;
if( $version =~ /^commit\s+([^.]+)\.\.\.$/ )
{ 
	$version = $1;
}
else
{
	$version = undef;
}
die "$0: No Git revision found" unless $version;
    
open(FH, "$INFO") or die "$0: $INFO: $!";
my $info = join("", );
close(FH);
    
$info =~ s/([\t ]+CFBundleVersion<\/key>\n[\t ]+).*?(<\/string>)/$1$version$2/;
    
open(FH, ">$INFO") or die "$0: $INFO: $!";
print FH $info;
close(FH);

Since git is distributed, there is no need to be online to produce a build. The script will grab the current abbrev-commit hash and will inject it into the current build’s Info.plist file.

 
4
Apr
2008
 

Cocoa Tutorial: Using NSError to Great Effect

by Marcus Zarra

Error handling is rarely fun. I find myself often re-coding a method after I realize that I need to handle one error condition or another. Usually, error handling involves either try/catch or some return code strategy. Neither of those is pretty or easy to maintain. For Objective-C development, however, there is another option — NSError.
(more…)

 
26
Mar
2008
 

Cocoa Tutorial: awakeFromNib vs applicationDidFinishLaunching

by Marcus Zarra

When developing an application in Objective-C and using Cocoa, there is a lot of “magic” that happens in the background. As we get more comfortable with the language and the APIs, we begin to discover the source of that magic and understand not only WHY it works but HOW it works.

One of those areas is the initialization and callbacks from the nib files to my code. Normally, when I want a controller to do something after the NIB/XIB has loaded, I add the method -(void)awakeFromNib and know that I will receive a call when all of the connections into the NIB/XIB are complete. But on what object does this get called and how?

(more…)

 
18
Mar
2008
 

Git and .mac: A Match Made In Purgatory

by Marcus Zarra

Last year, I made the switch from subversion to Git. After 9+ months of using Git, I can comfortably say that it was a very good choice. While branching is easy in subversion, merging is just as bad as it was in cvs. Git is a significant improvement over that. In addition, since Git is a true distributed source control system, I can easily do branches and merges on my local machine without an internet connection and just “push” my changes to my off-site server when it is convenient.

I am also a user of .mac. I like the service and the iDisk is probably my favorite feature. Therefore, I wondered, like chocolate and peanut butter, could I put these two together and come up with something better than the individual parts?
(more…)

 
11
Mar
2008
 

MacBook Air: Thoughts and Issues

by Marcus Zarra

For those of you who only read this blog for coding suggestions and tutorials — please hit next on your feed reader :)

For those who are also interested in our development environments, hardware, etc. then please read on.
(more…)

 
8
Mar
2008
 

Cocoa Tutorial: How to Crash Cocoa

by Marcus Zarra

This article is designed to serve multiple purposes. First, it is to educate which I hope that it will. Secondly, it is a personal memory so that if (when!) I run into this issue again, I will be able to use Google to find this post and remember why I am an idiot and why the default settings for things are not always the best settings.MenuCrash.zip

First as always, here is the project that goes with this article.

If you run this application you will see that it does basically nothing. The interesting part of this app is how it crashes. To crash this application, perform the following steps:

  1. Open the application.
  2. Select the Application menu.
  3. Select the About window.
  4. Close the About window.
  5. Open the Application menu again.

(more…)

 
7
Mar
2008
 

iWeb Buddy has been released!

by Marcus Zarra

iWebBuddyIcon.pngiWeb Buddy has gone Gold Master!

Marcus S. Zarra of Zarra Studios, released iWeb Buddy on March 6, 2007.

Do you like using iWeb but wished it had some advanced feature that you simply need for your website? Perhaps you want Google Analytics on your site or you want to add Social Bookmarks to your blog posts? Perhaps you just want to have more than one Domain file.

iWeb Buddy solves all of these issues for you! With iWeb Buddy you can “process” the pages generated by iWeb and add those pieces of html code or javascript that you need to make your site complete.

iWeb Buddy has the following features:

  • Multiple Domain files that open properly in iWeb.
  • Google Analytics injection.
  • Social Bookmarks (Digg, Slashdot, etc.)
  • Haloscan comments injection.
  • Mint site tracking.
  • RSS Feed redirection (for use with FeedBurner, etc.)
  • RSS Feed linking on blog entries.
  • Custom HTML body code
  • Custom HTML header code
  • And a lot more…

To find out more information about this new product, visit its product page.
(more…)

 
4
Mar
2008
 

MacDevNet Podcast: MDR005 Data

by Marcus Zarra

I had the pleasure recently of being on an episode of the Mac Developer’s Roundtable with Kevin Hoctor, Aaron Hillegas and Steve “Scotty” Scott. In this latest episode, Scotty introduced the topic of data, how to store it, access it, etc. To kick it off, Aaron delivered a fantastic history of Core Data or as it was originally called, Enterprise Objects.

I highly recommend this episode to anyone who is interested in Core Data and Cocoa in general.

You can get the episode from MacDevNet.com.

(more…)

 
3
Mar
2008
 

Core Animation Tutorial: Wizard Dialog with Transitions

by Marcus Zarra

A question that I have seen pop up a few times is how to build a Wizard in Cocoa. Having thought about that question a bit I realized that a better answer to it is — how to build a wizard in Cocoa using Core Animation.

The basic concept behind this project is to present a window to the user that will walk them through a list of options. To accomplish this task, I created a number of NSViews that will be presented to the user in order so that they can make the decisions needed. To make this a little easier, I have extended NSView to create MSZLinkedView. The added functionality in this subclass is that the view has a reference to the previous and next views in the wizard. These references are set in interface builder directly so that I do not have to worry about them in code.

(more…)

 
1
Mar
2008
 

Does Objective-C Perform Autoboxing on Primitives?

by Marcus Zarra

This article is inaccurate.


The writer was smoking crack or something when he wrote it and has not been able to duplicate his tests since. This article is left here for historical reasons.

One of the things about Objective-C that I find extremely useful is the ability to resolve a method call at runtime. In addition this same functionality allows us to do some fairly creative things with callbacks, passing messages between threads, etc.

However there is a bit of a trick when it comes to passing primitives though some of these methods. For example, one method that I use quite frequently is performSelectorOnMainThread:withObject:waitUntilDone:. How exactly does one pass a BOOL or an int to this method?
(more…)

 
20
Feb
2008
 

Cocoa Coding Practice: Old School vs New

by Marcus Zarra

Garbage Collection

This post is in response to a few queries that I have received regarding my last post showing an NSOperation example. One of the questions raised that I will focus on is my -(void)dealloc method in the NSOperation subclass. The questions boiled down to:

Why are you using releases at all. Garbage collection is the future!

and

You should be just doing [self setVar:nil] instead of that [var release], var = nil; crap.

(more…)