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 , , , | 2 Comments

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 | 1 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

Thoughtback has a new feature that will help you integrate it into your apps

One of the biggest requests we get for Thoughtback is an API. We’re working one but it’s not quite ready yet. In the meantime we have a way you can integrate Thoughtback into your own apps.

The way to do this is with the Thoughtback URL schema.

The URL schema will allow any app (even on the web) to send a thought through the Thoughtback app.

The easiest way to give it a try is to click this link or paste this string into your browser
thoughtback://send?thought=This was a great post&redirect=http://google.com

Method: send
Arguments: thought, redirect (optional)

thought: The thought you want to send
redirect: A URL to open after the thought is sent.

After the thought is sent, Thoughtback will open the URL and append a query string to it.
If sending the thought was a success, it will append the following query string.
?success=true&thought=A Random Thought

If sending the thought failed, it will append the following query string.
?success=false&error=The reason it failed

Thoughtback will use the currently logged in user to send the thought and return a thought from that same user. If Thoughtback isn’t installed, the URL will fail to load.

This works with both the Mac (v1.3+) and iPhone (v1.4+) apps so you can integrate on either platform. Hopefully this will help tide you over until our API is finished.

Posted in Uncategorized | Leave a comment

The perfect cable company

Here’s what I want from a cable company.

Everything on demand. I don’t want to bother with being home at a certain time to watch a TV show. If I want to watch the show, it should be available for me to watch. It needs to be available to watch on demand at the same time it’s broadcast.

TV Show subscriptions and queue management. I don’t want to have to remember when my favorite show becomes available. I want it to subscribe to them and it will automatically get added to my queue so I know it is available to watch. If I see a show I think looks interesting, I should be able to add it to my queue to watch later.

Old stuff is just as important as new stuff. I want to be able to pick from shows that are no longer on as well as shows that are still being made. Basically, if the show was ever on TV, I’d like to be able to watch it.

Sports, awards shows, and other important events need to be available live.

I don’t just want to have stuff on demand though. I still want to be able to channel surf. I still need something for background noise when I’m doing something else.

Everything should be pausable and rewindable. If I see something interesting, I should be able to watch it again. If I have to go to the bathroom, I don’t want to miss anything.

Everything should be available anywhere. I want to be able to watch it wherever I am with my TV, laptop, tablet, or phone.

I also don’t want to pay for stuff I don’t use. Right now I get hundreds of channels. I watch maybe 20 of them. I wouldn’t mind paying per show, or paying per channel.

Now this might seem like a pretty tall order, but none of the limitations are technical. Most of this can be done using services today. Hulu’s tv subscription and queue management is excellent. Any show I watch that is available on Hulu, I watch almost exclusively on Hulu. I can watch older shows on Netflix. All of this from just about any device. I don’t feel like I’m paying for things I don’t watch, which as awesome too.

Many live events are already streamed online, what’s missing is a way to aggregate them together with a consistent experience. I watched a football came from NBCSports.com the other day that was HD, offered multiple camera angles, and during commercials it showed tweets about the game. It was pretty awesome. Unfortunately, most Michigan games aren’t on NBC and I can’t always stream them.

How will these problems get solved? I don’t think Netflix, Hulu, or Youtube will solve these problems. These companies have to deal with all the crap from TV networks and movie studios. They’re going to be the ones that change the minds of the movie studios and allow new companies to come in and really innovate and solve problems.

Posted in Uncategorized | Leave a comment

Write bad code… to become a better developer

I’ve always thought I could measure my improvement as a developer by how bad my “bad code” is. You know what I mean by “bad code”. It’s the stuff you write on your little side projects or proof of concepts. It’s written as quickly as possible just to get a job done with very little concern to how it will end up working or how it will look when you come back to it in a few months. I don’t mean intentionally bad stuff. I just mean, you write it down as it comes to your mind. It might not be the best solution, but it is a solution.

I’ve found that over time, my bad code gets better. It started with simple things like not naming my variables a or b. Then it became things like breaking out separate classes sooner and sooner. I could tell by my speed too. Those things that I always used to look up I started to write by memory. Those 3 line if statements became functions. I’m better at understanding how whole programs should be structured and I am better at managing things when they start getting really big.

I think most bad code is written because it’s easier. It’s easier to copy and paste something 3 times than it is to write a loop isn’t it? At least until I want to change it to happen more than 3 times. At that point the bad code isn’t easier any more. How am I supposed to know if the easier code is actually going to make things harder later on? Experience. I won’t know if that shortcut is going to slow me down until I actually try it.

I like to write bad code as a first step. It lets me get a feel for what I’m writing. It’ll show me where the tricky bits are going to be and let’s me get my ideas out quickly. As I find the hard parts, I can go back and rework my solution until it’s better. The less I need to change that quick and dirty code, the better I think I’m doing as a developer.

I’m not trying to say that you should always do things this way, but it seems to be a great way to measure how I’ve grown as a developer. Remember, code quality is highly subjective. What seems beautiful and elegant to me, might look complicated and stupid to you. I read something once that said something like “If you look back at your old code, it should always look bad. If it doesn’t you aren’t learning anything.”

Posted in Uncategorized | Tagged | Leave a comment

Adding a button or view to the NSWindow title bar

I’ve seen some apps that put buttons inside of an NSWindow title bar. If you try to do this yourself, you’ll notice that Interface Builder won’t let you put anything there. So how do you put something there?

The way to do it is to get your window’s contentView’s superview. Put more simply [[window contentView]
superview]
. The problem with this is that this view includes the whole window, including the title bar. It’s not too hard to figure out where to place the view you want to add, but why do it when someone else has.

I wrote a category that will let you pick the x position in the title bar and fill the height of the bar with whatever view you put in it. I figure out that height by calculating the difference between the window frame and the contentView frame.

So how does it work? Continue reading

Posted in Uncategorized | 1 Comment

How to open any file you drag onto your app’s dock icon

One of the most important aspects of the OS X interface paradigm is drag and drop. One of the best places to support drag and drop is on your dock icon, because it is always available no matter where you’re dragging from. It won’t be hidden behind a window or lost on some other space.

So how do you make it so that your app will accept files dragged onto it’s dock icon (aka dock tile)? It’s pretty easy. You’re just going to add something to your apps info.plist.

The key you’ll add is called CFBundleDocumentTypes. Then you’ll add information about the types of files you want to support. Maybe you want to open just image or just text files. Lots of this functionality should be automatically built in to your app if it is document based.

You can do this a slightly prettier way in Xcode 4 by looking at the info tab of your app target’s properties page.

Using * as the extension will let your app accept any type of file on it’s dock icon. Setting the role to Viewer tells the OS that you are only going to look at the files, not modify them.

So now your app’s dock icon should highlight when a file is dragged onto it. What now? Continue reading

Posted in Uncategorized | Leave a comment