Eval Expression service for OS X

Eval Expression is a Mac OS X service to evaluate the selected text of any text field as a Ruby expression. My instinct was to choose Perl, however Ruby offers binary in addition to decimal, hex and octal numerical literals. The service becomes infinitely more useful if you assign it a global shortcut in Keyboard preferences. In my case I assigned a combination that seemed obvious, ⌘= It came about as I was working on some layout in Xcode 4 / Interface Builder, and needed to adjust the Y position of a view by a specific number of units. Read On →

Mobile Safari performance and executable pages in iOS 4.3

DaringFireball recently posted his thoughts as to why the Javascript performance of Mobile Safari is faster than those launched from SpringBoard or within existing applications which use a UIWebView. I don’t think it’s quite that complicated. My thoughts are it is one of two things: Apple is concerned about security (which would support John’s theory) Mobile Safari is binding to a newer and/or private version of Webkit, and Springboard was an oversight Apple is concerned about breaking existing applications I would argue this makes the most sense, and was probably a very deliberate action by Apple, given enabling Nitro is a significant enough change to a core framework that could break existing applications. Read On →

Renew Apple developer certificates with OpenSSL

I like to reuse the same private keys when generating a signing request to renew my Apple developer certificates. Unfortunately you can’t do this with Keychain Access, as it won’t save the signing request file after you step through the wizard. OpenSSL is your friend. Open Keychain Access, RMB on the key your wish to use and click Export “[Key Name]”. Save it as a .p12 file with a strong password. Read On →

Micro-benchmarking iOS devices

Update: Added iPhone 5. Update: Added iPhone 4s, iPad 3rd gen. Update: Added iPhone 4, iPad 1st gen. I follow the excellent weekly posts by Mike Ash, and entered a brief discussion in comments about toll free bridging. In particular, the difference between calling a method via Objective-C (objc_msgSend) and it’s equivalent CoreFoundation C call. Mike suggested adding it to his original suite of tests, which lead to the following results. Read On →

Enable -Wformat for better compile time help

Let the compiler do all the hard work, and be sure to enable the following warning: It does more than just validate printf/scanf formatting calls, which is helpful in itself. It also validates that a sentinel is present in variadic functions. A sentinel is typically NULL or nil for the last parameter. A common place you would benefit from this is using the arrayWithObjects method of NSArray, that requires a nil for the last value. Read On →

Xcode Tip: Generate comments in your assembler output

To make it easier to find the assembly generated when you ‘Show Assembly Code’, embed comments using: asm("# your comment")

How to debug handleOpenURL

I’ve seen a number of questions on the Apple iPhone developer forums asking how to debug the UIApplication handleOpenURL message. I finally had a complex scenario that I needed to debug, and came up with the following solution. Note that this example has been tested using the simulator only. Firstly, you’ll need to grab the two ‘DebugSupport’ files from my google code repository here. Include them in your project and modify your handleOpenURL message as follows: -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { [DebugSupport waitForDebugger]; ... Read On →