Xcode keyboard tricks

I’m mostly a keyboard navigation type of user, so it’s been a few busy months trying to remember all of the different little tricks in Xcode while doing Objective-C work.

A few of my favorites:

  • ⌘ + l (lowercase L) – if done within a text editor pane, it will re-center the editor around the line that the cursor is currently in. Too confusing? Try this video demonstration from Todd Ditchendorf then.
  • ⌘ + option + up arrow – switches between header (.h) and implementation (.m) files.
  • ⌘ + b – builds project.
  • ⌘ + r – build and run project.
  • If you hold down the alt/option key, and then double click on a code token, such as a class name or function name, it will automatically search the documentation for that particular word. Very useful when you want to read some more about the UITableView class, for instance.
  • A similar trick is available if you would like to open the definition for a particular code token, such as the source code file where class ExampleController is defined. Just hold down the command key (⌘), and double click the word.

Creating UIColor objects from hex values

It’s pretty inconvenient to create UIColor objects while developing apps for the iPhone, as you need to specific separate values for the RGB parts: red, green, blue.

I found a trick online a few weeks ago on how to automatically generate that code, by simply using a macro:

#define UIColorFromRGB(rgbValue) [UIColor \
    colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
    green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
    blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

The usage looks something like this:

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (nil == cell) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"cell"] autorelease];
    cell.textColor = UIColorFromRGB(0x333333);
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.text = @"Testing 1 2 3";

Hope that’s useful to someone.

iPhone 3G first impressions

It’s been close to 10 days now with the new iPhone and I wanted to write down my impressions.

The bad:

  • Battery life is terrible. I mean, I understand the usual fanboy tactics of saying that the iPhone 3G still has the best battery life among 3G phones, but who the hell cares? It still sucks, I still have to charge the damn thing at least two times a day.
  • It crashes a lot. I mean a lot lot.
  • No idea why, but deleting emails from a specific IMAP account that I have, completely disables the Mail app against any other account. I have to restart the whole phone to be able to use that app again.
  • Every so often iTunes does a backup of the phone, and it is now taking a LOT of time. I remember it taking around 1 hour for the first time. I believe it takes that long when you install new applications on the phone, but it makes no sense to me to take that much time.
  • The contacts app takes a lot of time to open now. I’m assuming this has to do with a new architecture that allows one to search the database, but damn. 4-5 seconds to load a contact database of 73 contacts? Come on.
  • The App store needs to review new applications / updates to existing apps more quickly.
  • The store should restrict app reviews to users that actually purchased the app.
  • A small thing, but it’s quite common for the phone to stop doing the “unlock” sound. You know, the one that is triggered when you unlock the phone with a sliding motion. The “lock” sound still works, but the “unlock” one doesn’t. I need to restart the machine to make it work again.

The good:

  • The App store is so very cool. Lots of cool apps available, and I’m sure many more will come in the future.
  • Exchange support is very useful. I can finally sync with my work’s email account with ease, without doing a lot of IMAP/procmail hacks.
  • The new “tap at the top of the screen” to scroll to the top of the list of email messages is awesome, something I wanted for a long time.
  • Same feature is now available in the contacts app.
  • Being able to delete multiple messages is also invaluable. I can’t believe how much time I wasted in the past deleting a whole bunch of spam.
  • The sound quality seems much better. The speakers are much better as well.
  • The ability to save images into your photo folders is awesome.

Customizing the message display layout in pine

I’ve been using pine for a long time now — I remember it was the default mail client available at my university‘s computer sciencie department. If I remember correctly, I think it was the first program I ever used in a UNIX system (back in 96?).

In any case, after more than a decade using this program, I just found out that you can customize the display of the message list within a folder. I noticed that the list of messages looked different while browsing the Wikipedia entry for Alpine.

My personal setting now is:


If you go into the configuration section, search for the “index-format” entry (^W index-format), and then hit ? to go to the online help entry, you will get access to all of the documentation available for this. Very cool stuff.

Follow-up on HttpWatch integration with Selenium

Simon Perkins of Simtec Ltd (makers of the HttpWatch plugin for Internet Explorer that I mentioned before) was kind enough to get in touch with me via email about my wishlist for YSlow / HttpWatch / AOL Pagetest.

He wasn’t familiar with Selenium, but said that it might be possible to hook up HttpWatch to retrieve performance data dynamically. He pointed to a blog post describing how to do so with Watir, an automated web testing tool written in Ruby. Simtec even has a tutorial about this on their own web site.

While that does sound interesting, it looks like Watir interfaces with HttpWatch with a COM object on Windows, and that’s how it gets the performance information.

The way to do this integration with Selenium would be to expose a set of JavaScript APIs (maybe the same set of objects available through the COM layer?), so one could write JavaScript code to export the HttpWatch information. That’s really what I would love to see.

If that was available, I could write a simple Selenium RC test suite in PHP, remote control a set of browsers from my Linux box, and get access to this performance data from HttpWatch by simply running some JavaScript function.

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »