The Big Nerd Ranch weblog has a new post about Objective-C 2.0 dot notation. They advocate never using it and they’re completely wrong. Given my reaction on Twitter, several people have asked me to write a more in-depth rebuttal. I’ve already addressed when and why you should use Objective-C 2.0 properties and dot notation in […]
In the past, I’ve talked about ways to easily write unit tests for Cocoa applications, including [tests for user interfaces using target-action][1] and [tests for interfaces using Cocoa bindings][2]. There are some strategies you can apply to make writing tests for Cocoa code even easier, though. They’re just straightforward object-oriented programming, but sometimes we can […]
I’ve occasionally been asked about the appropriate form for properties representing to-many relationships in Objective-C 2.0. Let’s start with the example of a recipe and its ingredients, represented by instances of the Recipe and Ingredient classes. @interface Recipe : NSObject { @private NSMutableSet *_ingredients; } @property (copy) NSSet *ingredients; @end This is a pretty straightforward […]
I’ll preface this post with the standard advice: *Don’t create singletons if you don’t absolutely have to.* In general, if you’re creating a global “manager” object of some sort, you’re doing something wrong. That said, there’s still occasionally a reason to have such a global singleton, such as a “default something.” The sample code in […]
I listened to a recent episode of the [cocoaFusion:][1] podcast about properties and dot notation today. There were a few interesting points brought up, but I felt a couple of the most important reasons to use `@property` declarations and dot notation weren’t addressed. The biggest reason I see to use a different notation for both […]
In a few weeks, it will be **four years** since Mac OS X 10.4 Tiger was first released. That was the first release to include Core Data. It will also be about **one and a half years** since Mac OS X 10.5 Leopard was released, with significant enhancements to the Core Data API. It’s pretty […]
What’s wrong with this code? – (void)registerForNotificationsFromTask:(NSTask *)task ( { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidTerminateNotification:) name:@”NSTaskDidTerminateNotification” object:task]; } If you didn’t notice anything wrong, look again. What’s bad about this is that it’s passing a **string literal** instead of a **global variable** for the notification name. The code should really look like this: – (void)registerForNotificationsFromTask:(NSTask *)task […]
I’d like to make it to NSCoder Night tonight, but I just have too much else to do today — again. I won’t be seeing anyone at NSCoder Night next week, either, as I’ll be in San Francisco for the Apple Worldwide Developers Conference! If you’re attending, be sure to find me and say hi!
I’d like to make it to NSCoder Night tonight, but I just have too much else to do today. Hopefully I’ll see everyone there next week!
The next CocoaHeads Silicon Valley meeting will be on Thursday, May 15, 2008 — that’s tonight! — at 7:30 in the Garage 1 meeting room at Infinite Loop 4 on Apple’s main campus. That’s inside and upstairs at Apple’s Infinite Loop campus in Cupertino. See the web site for directions. This month’s main presentation is […]