February 20th, 2009
How to Calculate Pi by Throwing Frozen Hot Dogs
Believe it or not, of all the countless ways to approximate the most prolific irrational number in the universe, there are none quite as interesting or as surprisingly satisfying as throwing perfectly good food around your kitchen.
I haven’t tried this, but I will admit it looks extremely satisfying.
Tags: Link, pi
Posted in Link | No Comments »
February 8th, 2009
What is the world coming to when we have nerd-on-nerd violence, reported by nerds?
Pic Shows Man Robbing Stores With Klingon Sword – Irresistible Headlines News Story – KMGH Denver
Yes, I said nerd on nerd. Note this:
Both clerks described the weapon as a Star Trek Klingon-type sword, called a “bat’leth.”
And reported by nerds? Note this:
The Startrek.com Web site describes the Klingon weapon as crescent-shaped and about a yard long. However, the weapon that the man was wielding appears to be smaller than that. The bat’leth has points on both ends, two points in between and a handle on the outside.
I say again: NERD.
Tags: crime, nerd, robbery, Star Trek, violence
Posted in Articles | No Comments »
February 2nd, 2009
If any of these seem wrong, please comment!
- The Objective-C syntax is strange. It’s really not that hard, though, especially once you realize that part of the reason for the design was to make Objective-C a strict superset of C. That means that the C code you throw at it will compile and means the same thing under C as Objective-C.
- Use
NULL for pointers (void*) and nil for instances (NSObject*). They’re defined the same, this is just convention.
- Use properties and stay sane. You can leave the dot syntax alone if you like (though I like it), but it’s worth using properties anyway because it forces you to document the assignment mechanism you’re using.
- Method names that return an object where the name does not contain
init must not require the object be released.
- If you’re writing the object, this means you’re probably calling
retain and autorelease.
- If you’re using the object, this means it is probably already calling
autorelease. If you release the instance yourself, you’ll crash later.
- Use
alloc, init on the same line.
- If you’re going to
autorelease an object, do it at immediately on creation rather than later: [[[Object alloc] init] autorelease].
- Sure, you can avoid using
autorelease. Sure, it would perform “better”. But can you quantify “better”? Is it significant to you? If it isn’t, stick with using autorelease. When you follow the rules, you idiotproof yourself. See the probably in the previous group of points? Stick with the rules and it’s basically an “always.”
- Remember that debugging is harder than writing code. While you can write something like
textView.text = [NSString stringWithFormat:@"%@: %d", [b field:@"test"], [a precision]]; you are going to have to debug it later. In most cases, you’ll benefit from assigning results to temporary variables before passing them through to Cocoa.
I’m going to write about the major device vs. simulator differences I’ve noticed another time, but there’s one worth mentioning now: CGSize size = [string sizeWithFont:font] with a nil string will return a zero point on the desktop, but will return a random value (stack, maybe?) on the device itself. Check for nil first, as in CGSize size = string ? [string sizeWithFont:font] : CGSizeZero.
Tags: Cocoa Touch, iphonesdk, software development
Posted in Articles | No Comments »
January 24th, 2009
Matt Gallagher posts on multiple virtual pages in a UIScrollView using just 2 child views:
The UIScrollView and UIPageControl in Cocoa Touch allow for user interfaces with multiple panning pages. The sample project that Apple provides (PageControl) keeps all child views for every page in a lazily loaded array. I’ll show you how you can implement this using just two child views, no matter how many virtual pages you wish to represent.
Caveat emptor on this technique, I suppose. You are going not going perfectly along Cocoa Touch’s grain. Probably best used when dealing with a large number of views.
I actually tried something like this before settling on a more basic approach like Apple’s PageControl sample code. But I ran into a problem which I thought was related, but turned out not to be: UITextView wouldn’t update when offscreen.
Turns out Matt has a solution to that, too:
These parts of the program exist because UITextView (used for the “Some text for Page X” display) don’t update if they are offscreen (in this case: in an offscreen page of the UIScrollView). This behavior isn’t a problem when the UITextView remains offscreen but becomes especially annoying when it is brought onscreen and still doesn’t update.
What a weight off my mind that is!
Full project and source included. Thanks Matt.
Tags: Cocoa Touch, cool hack, software development
Posted in Link | No Comments »
January 23rd, 2009
Small but nice iPhone application wording tip: “My” vs “Your”. I’d have fallen for that one for sure, but he’s right.
Tags: iPhone, software development
Posted in Link | No Comments »
January 22nd, 2009
Ars Technica discovers an Apple support document explaining that boxed, retail copies of iWork 09 do not require a serial number. An interesting choice by Apple.
Tags: Apple, iwork
Posted in Link | No Comments »
January 20th, 2009
These instructions are for the Collabnet build, but you can use MacPorts build instead by replacing the path /opt/subversion/lib/ with /opt/local/lib/.
Lemon Team’s blog » Blog Archive » Setting up Subversion 1.5 on Xcode
Tags: software development, subversion, Xcode
Posted in Link | No Comments »
January 15th, 2009
Posted in Link | No Comments »
January 11th, 2009
A few thoughts, based on watching the keynote via QuickTime:
- Phil Schiller was great. He seemed to be a little nervous in his delivery, but he was interesting in a casual, friendly way. If he has a chance to do some of Apple’s special events in the future, he’ll be a little less awkward.
- From any other company, this would have been a slam dunk, and people who are unhappy are clearly expecting too much.
- The iLife 09 upgrades make it a must-have purchase for me. I’m looking forward to working through the Garage Band tutorials, and iPhoto face and location metadata is an omission I’ve been struggling to find workarounds to. And as an owner of a Flip Ultra, I’m really looking forward to having image stabilization.
- The 17″ MacBook built-in battery seems like a great trade-off to me. I don’t have two batteries anymore, I just replace the one I have when it won’t hold enough charge anymore. It sounds like that will still be possible.
- I’m really happy to see DRM-free music on the iTunes Store. I’m less impressed with the all-or-nothing upgrade, but will probably upgrade sooner or later.
Tags: Apple, Flip Ultra, iLife, iTunes Store, keynote, MacBook
Posted in Articles | No Comments »
December 22nd, 2008
Here’s iCal’s View menu.

What’s so confusing about it? You really need to see how it interacts with the iCal main window to understand. We’re going to be focusing on the group starting with “Hide Calendar List.”
The iCal main window looks like this:

The sidebar on the left side of the screen looks simple enough. Now let’s look again at the menu. What would you expect Hide Calendar List to do?
Wrong. It does this:

Both the calendar and mini month calendar are hidden. Hiding both makes sense, but calling the command Hide Calendar List doesn’t. Go back to the menu, and we see the helpful command “Hide Mini Months.” What Mini Months? Oh, the ones that were on the iCal window, but aren’t anymore? I wonder what it does?
It does this:

That’s right. Choosing Hide Mini Months showed the mini calendar.
So here’s how the menu commands work:
The first command, Show/Hide Calendar List, hides the entire left side bar: The calendar list and whatever is under it.
The second and third commands, Show/Hide Mini Months/Notifications, control what’s under the calendar list, but still controlled with the Show/Hide Calendar List command. And they don’t actually do what they say they’re going to do if the calendar lis is hidden. They’re mutually exclusive: Think of them as Under Calendar List: None, Mini Months, or Notifications.
The fourth and fifth items are entirely independent of the first three items.
Granted, coming up with menu commands to control a UI like this is hard. But that’s no excuse to throw your hands in the air and settle on this UI.
Tags: Apple, bad user interface, Hall of Shame, iCal, Mac OS X
Posted in Articles | No Comments »