Afternoon Apps 2: Scrumbled

A few weeks ago I made an app called Descrumbled for cheating at Boggle. I wanted to see if I could build an app in a single afternoon. I built it and released it in one day. The next weekend, I found myself with some more free time and I decided to see if I could do it again. The idea was that I would take my Boggle cheating app and turn it in to a Boggle playing app. So I branched Descrumbled and got to work.

The hardest part of a Boggle app is knowing what words are valid. You need to take a grid of 16 letters and evaluate the thousands of possible combinations against a dictionary of over 200,000 words. Luckily, that was already done.

I didn’t want this to be quite as simple as Descrumbled. I wanted to make it actually worth playing. To do this I added Game Center achievements and a social challenge option.

Basically, there are achievements designed to get you to play the game more. The achievements require you to do things like play 100 games and get certain high scores. There is also a leader board that people can use to see how they stack up against the rest of the world.

Achievements and leader boards are great, but I wanted to add a little bit of a multiplayer aspect to the game. So I added a feature so you can send someone a game board as a challenge. When they click the link in a text, tweet, or email it will open up that game board and let you play it.

The only other sort of interesting thing I did was with advertising. Instead of relying only on iAds, I put in an ad of my own, for Descrumbled. Sometimes iAds fail to load. When that happens, I show a button with an ad for Descrumbled asking the user if their puzzles are too hard. It’s not super exciting, but it might drive a few more people to download one of my apps and it looks better than a blank space where the ad didn’t load.

This app didn’t take a single afternoon. I think I spent probably 3 afternoons on it. When I had it mostly working, I decided to add the social challenge feature and had to change the way the app was architected. That took a little bit more time than I wanted it to.

Be sure to check it out and let me know what you think.

Posted in Afternoon Apps, Uncategorized | Tagged , , , | Leave a comment

Taking control of the volume buttons on iOS, like Camera+

Camera+ just got VolumeSnap back in their app. If you don’t know the story, Camera+ used the volume button on the iPhone to snap a picture. Apple rejected their app and kept them out of the store for three months when they found out. Then when iOS 5 came out Apple implemented volume snap in their own camera app. So now that Camera+ has it again and Apple seems to have relaxed their policy, I tried to figure out how Camera+ did it.

I came up with this class RBVolumeButtons. You use it like this:

   RBVolumeButtons *buttonStealer = [[[RBVolumeButtons alloc] init] autorelease];
   buttonStealer.upBlock = ^{
      counter++;
      [counterLabel setText:[NSString stringWithFormat:@"%i",counter]];
   };
   buttonStealer.downBlock = ^{
      counter--;
      [counterLabel setText:[NSString stringWithFormat:@"%i",counter]];
   };

It’s really that simple. Here’s how I did it.
Continue reading

Posted in Uncategorized | 7 Comments

Afternoon Apps: Descrumbled

At events like Startup Weekend, you try to build an idea in a weekend. I wanted to see if I could do something even faster. So I bring you Afternoon Apps, where I build an app in a single afternoon.

Descrumbled is an app for solving Boggle puzzles. Boggle is a word game where you have to find words hidden in a grid of letters. The app lets you enter a board and quickly generate all possible words that can be found in the puzzle. It uses the SOWPODS dictionary to see if a word is valid or not.

I was able to build the app in an afternoon because it is very simple. It lets you pick two board sizes, 4×4 and 5×5. Then you can enter the board, press solve, and seconds later you get a list of all the words. Pressing a word will give you the definition thanks to iOS 5′s dictionary integration.

The hard part was actually solving the puzzle. Generating all the possible words in the puzzle and checking them against a 230,000 word dictionary is no trivial task. I’m going to let you in on a little secret. I didn’t write the boggle solver in a single afternoon. I had written it before by working on it a few hours a day for 3 or so days. It was a programming challenge I found online and I tried to do it. It’s actually a lot of fun solving a problem like this. I get to think about tries and binary searches. Things I haven’t actually had to think much about since college. My first stab at it took about 3 minutes to solve a 4×4 puzzle. Since most online Boggle rounds are 1 or 2 minutes, this obviously wasn’t acceptable. I improved my algorithm and now it takes ~1 second to solve a 5×5 puzzle.

So what did I actually do in an afternoon? I built a UI around my boggle solver class. I had to get a C++ class working on the iPhone (which is actually really easy) and build a UI for entering the board. The squares on the board auto advance the cursor through a grid of UITextFields. It also makes sure the board is complete before it tries to solve. Then I had to make a way to clear the board and switch between a 4×4 grid and a 5×5 grid. The word list UI is just a very simple UITableView. When you press a row, it will open up the definition of the word in a UIReferenceLibraryViewController (new in iOS 5).

That’s it. The app is meant to be simple and easy to use. It really is a minimum viable product. I did this as an exercise to see if I could build a simple app and submit it to the app store in an afternoon. I want to keep doing these Afternoon Apps every few weeks. I’d love to see if other people have done similar things and find out how your experience went.

The app should be live any day now. Check it out!

Posted in Afternoon Apps | Tagged , , , | 5 Comments

Making your iPhone app look great on an iPad

Running an iPhone app on an iPad isn’t the best experience. It doesn’t use the iPad keyboard and everything looks very pixelated. Ideally, you would build an iPad version of your app, but that’s not always worthwhile. The iPad is a very different beast than the iPhone and it usually involves creating a completely unique experience for your app. So how can you make your iPhone app look better on an iPad?

Images. With the iPhone 4, Apple introduced an image naming schema that would allow you to load large images for the retina display and small ones for devices without it.

When the iPad launches an iPhone app, it launches it at the original iPhone resolution of 320×480. When you press the 2x button on the iPad it will stretch it out to 640×960 (the same resolution as the retina display).

This stretching, makes everything double in size and it all looks pixelated. So if you have an image that is 100 pixels wide, it will become 200 pixels wide and look like crap. But what happens if the image you provide is already 200 pixels wide?

It turns out that it looks pretty good. It shows up at the correct resolution with no pixelation.

The only problem with this is that if you give it a low res image, it will load it. Then it stretches and looks like crap. What you need to do is forget about the low res images and just include hi-res images.

“Won’t it look bad on the iPhone 3GS?” No. It’ll look fine. It’s scaling by half. Even the most rudimentary scaling algorithms look fine when it’s perfectly halved. You might lose a little bit of detail on some images, but it’s not much more detail than you’d lose using Photoshop to scale the images. Nobody will notice.

You can use the @2x naming convention if you want to, the images will all load just fine. There is a bug in Xcode 4′s interface builder that causes it to fail to load the images unless you put the @2x in the image name. This used to work in Xcode 3 before.

Including 2 images now is kind of silly. It makes the app larger (which can prevent you from downloading over 3G) and adds extra files that you need to manage. It’s easy to misname an image and end up with a pixelated piece of crap on your phone. The large images look just fine on the low res screens. I promise. It’s really too bad that iOS doesn’t render an iPhone app at the larger resolution on the iPad. It already knows how to draw the app at the double resolution for the retina display. Maybe with iOS 6.0.

Posted in Uncategorized | Tagged | 2 Comments

Building a static library that works on the iPhone and the simulator

Apple’s iPhone simulator runs really smooth and fast. This is because they aren’t emulating the ARM code on your Mac, they’re actually building x86 binaries that will run in the simulator.

Because of this, code written for the iPhone needs to be compiled twice, once for the simulator and once for the device. This makes working with static libraries a bit of a pain, because you need two of them, one for each architecture.

Luckily, it’s possible to build a “universal” binary that will work with both architectures. Apple did this during their switch from PowerPC to Intel.
Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

How to change the color of UIBarButtonItem on iOS 5

My most popular blog post is how to change the color of a UIBarButtonItem. It’s something that lots of people want to do, but it involved some pretty weird hacks to get it working.

Now that iOS 5 is out, I can talk about a better way to do it. Apple will now let you set the tintColor: property on the bar button item. That’s it. No more weird hacks with images or segmented controls.

There’s even a cool new appearance proxy that will let you change all controls from your app with a single line of code. (More about UIAppearance here)

So lets say you want every UIBarButtonItem in your application to be blue. That’s easy just call [UIBarButtonItem appearance] setTintColor:[UIColor blueColor]]

Remember, this is iOS 5 only. If you want your app to support iOS 4, you’ll have to do it the old way.

Posted in Uncategorized | Tagged , , , | 1 Comment

How to send text messages using the Twilio API on Mac OS X and iPhone

You may never have heard of Twilio, but odds are good that you use a product powered by their software. Twilio lets you send text messages and make phone calls using their API. They take care of all the details of working with the phone carriers and abstract it into an easy to use API.

Twilio has a variety of ways to use their services and the easiest one to use on the Mac/iPhone is their REST API. This lets you make a simple network request and send a text message. Here is how you use it.
Continue reading

Posted in Uncategorized | Leave a comment

Introducing: HappyCampfire, a Campfire framework for OS X and iOS

One of my favorite tools that I use at work is Campfire. If you haven’t heard of Campfire, it’s a group chat web app built by 37 signals. It’s very easy to use and has some fun features. One day I started playing around with the Campfire API to see what could be done and from that came the app I’m working on called HappyCampr. From that app, came the framework HappyCampfire.

HappyCampfire is an objective-c wrapper around most of the Campfire API. It has model objects like users, messages, and rooms. It should allow anyone familiar with Cocoa programming to get right to work on using the Campfire API. It is designed to work on both OS X and iOS but most of the work/testing has been on OS X.

I wanted to put this out there to help people make good innovative uses of Campfire, without having to deal with too many of the nitty gritty details. It’s definitely still a bit of a work in progress so feel free to fork it and send me a pull request if want to fix/add anything. Continue reading

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Don’t make me pick a unique username ever again.

You all know the feeling. You’re trying to sign up for the new big thing and the username you want is taken. After 2 or 3 tries you eventually give up or end up adding a number to the end or using something you’ll promptly forget about. Lets say you did actually get up and running. After a few minutes you leave the site and go on with your day.

You go to log in and you forgot your password. Maybe you didn’t forget your password, maybe your username is wrong. Well crap, which is it? You hit the forgot password link. Now it’s asking for your email. Great, you got a password reset email. You still don’t know which username you used.

Why the hell did you need a username for this anyway? Wouldn’t an email suffice? “But I want to show off my individuality” you say. Ok, great, you can pick a display name or something after you sign up. It doesn’t have to be unique either. It’s not like your name in real life is unique. Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

How to make your app window look like the Mac App Store, Twitter, and Chrome

A while back, Apple moved the window buttons on iTunes onto the left edge of the window. A lot of people hated it and they changed it back. With the Mac App Store, they moved the buttons again. This time they just moved them down. This is a trend you may have seen in a lot of apps. Apps like Twitter, GitHub, and Google Chrome all do this. Some like it, some don’t.

Here is a simple tutorial on how to do it. (tl;dr example project)

Continue reading

Posted in Uncategorized | 1 Comment