The first one uses the “C”-style “%s” format field for the string, which is incompatible with the NSString type string. It will subsequently scatter your files in seemingly random directories filled with jibberish in their names causing you untold hours of grief as you try to find them in what you believe to be the correct locations. The second one uses the correct “%@” format field. The moral of the story is that C and Objective-C are different in subtle but painfully significant ways…

Sometimes I suspect that my life is actually a series of cautionary tales for others.

(Actually, Mom’s birthday was Saturday, but this is my first post since then. Since it was her birthday and I know she reads this, I’m dedicating this post to her.)

According to the Chinese astrological calendar (which the Japanese also use), my mom was born in the Year of the Monkey. As it happens, she’s just like a monkey in that she’s very inquisitive and smart. She went off to college in a completely new city away from her home town and then she traveled to America where she met and married my dad. These days, she’s still learning new things like how to drive and how to use the computer. She’s an inspiration to my brother and me to keep trying new things. (Like, creating apps for the iPhone!)

I drew the above card for her birthday. It’s supposed to be a bunch of snow monkeys relaxing around in a hot spring. For reference, I used some friends’ photographs taken in Nagoya, Japan where snow monkeys really do lounge around in natural hot springs. Man, that would be a sweet life.

As you might have guessed from my last name (Kobayashi), I’m Japanese. More specifically, I was born and raised in the US, but my ancestors were from Japan. Even more specifically, my mom’s from Osaka, Japan where I spent a few summers as a kid.

I used to wonder if it had much effect on me to have spent so much time in Osaka and then I see something like this:

One of the laserdiscs we got was American Boyfriends, which is about a group of Canadian girls and the “wild” adventures they have on a road trip to America. Yeah … it’s about as exciting as it sounds. Anyways, after watching it, I turn to Tracy and we have this conversation:

“We can put that on the pile of discs to sell.”

“But what if someone comes over some day, sees it and says, ‘ooh, American Boyfriends! I remember that movie from when I was a kid. Let’s watch that!’?”

“…”

“?”

“Few things in this life are certain. But one thing that I do know from the very depths of my soul is that that would never happen.”

Hey! Remember Betamax? Neither do I. But I do remember Laserdiscs. A lot of people are getting rid of their laserdisc collections because DVDs and Bluray have rendered them obsolete. Also, everyone’s laserdisc players have broken down. But not ours! So we’ve been collecting free laserdiscs from various people who no longer want them.

Apparently, there have been over 500 million app downloads and about 20,000 apps on the iTunes store. According to apptism.com, the breakdown is something like 4,832 free apps and 15,764 paid apps. But the real question is how many downloads does the average app get?

Well, let’s speculate that the average free app get downloaded 10 times as much as the average paid app. (Hey, at least it sounds plausible, right?) If that’s true, then with a little algebra (10 * x * 4,832 + x * 15,764 = 500,000,000), we can extrapolate about 7,800 downloads for the average paid app and 78,000 downloads for the average free app. Pretty cool…

I’ve written little programs and games on other platforms but it’s never been like this until now. And that’s the greatest thing about developing for the iPhone / iPod — it gives small developers and hobbyists like me a chance to reach a bigger audience than ever before.

If you’re doing 3D graphics on the iPhone, you’re mostly dealing with OpenGL. And if you’re doing OpenGL, you’re using glBlendFunc(GLenum source_factor, GLenum destination_factor) to indicate how polygons draw on top of each other. The way it works is it multiplies a source image (what you’re putting on top) by something, multiplies the destination image (the background) by something, and adds the two results together. The glBlendFunc() specifies what those two somethings are.

Here are a few examples from my own code:

The source image is just a circle that's half black and half white. The destination is a background image that comes with the iPhone simulator.

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

This is the standard operation, which is used 99% of the time. It specifies that you multiply the source image by one, which leaves is alone, and multiply the background by (1 - source_alpha), which cuts a hole for the source image to fit in. I've also seen examples which replace the first GL_ONE with GL_SRC_ALPHA but in my experience, images with transparency tend to be pre-multiplied so GL_ONE is more correct.

glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);

This is pretty much like the last example, except that we multiply the source image by zero so that all we're left with is a hole in the shape of the source image.

glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);

I've used this combination to blend or tint the background. For example, I used this on Mach Dice to burn shadows on backgrounds. It works by multiplying the source and destination images together and plopping it on top of the hole cut out of the background.

glBlendFunc(GL_DST_COLOR, GL_ONE);

This is pretty much just like the previous example except that a hole isn't cut out of the background. The result? The tinted image is added on top of the background making it lighter. I've used this to create highlights on backgrounds.

I was going to do a post today about glBlendFunc and a few of the different ways you can use it to get different effects. But over the weekend, I got a chance to go on a trip to check out the elephant seals in Ano Nuevo State Park. So you’re going to hear about that first.

Elephant seals are big. I mean, really big. The biggest ones can get about 15 feet long and up to 5000 pounds heavy. To give you an idea of what that’s like, imagine three of me lined up on the floor. Now drop another 40 of me in a pile on top of that. And that’s about how big they can get.

They can also move surprisingly fast. The shuffle their bulk in a sort of … waddle-gallop? galumph? I’m not sure what you call it. But it’s pretty impressive. Check them out if you ever get the chance.

Humor is a funny thing. (Har, har.) It’s very individual and yet universal at the same time. As a kid, I was fascinated but also confused by it. I remember obsessively reading each of the comics in the Sunday paper, trying to figure out what made them funny but mostly I’d ask my dad. My parents never really told jokes or anything like that but I do remember them laughing at things we did or said. They were both pretty literal as well, so for the longest time, I didn’t “get” sarcasm. Boy, that made for some awkward times in high school and college. (“Hey guys, that girl said I’m totally her type!”) Good times, good times…

Anyways, I started thinking about this whole thing recently because I just recently ran across a phrase that made me go, “Wow, yes, that phrase perfectly describes my concept of what I think is funny.” It’s actually a title of a book. I don’t know if it’s any good or even if it’s out yet. But as a phrase, it’s pure awesome. And that phrase is: “Pride and Prejudice and Zombies“. (The italics are mine because that’s the part that’s awesome but I have to admit, I do have a thing for Jane Austin novels.)