Archives for category: iPhoneDev

How many times have you done a Find in Project (Command-Shift-F) in TextMate and accidentally searched through your Rails development.log or your Xcode build files?

TextMate tries to read these massive files and your whole machine grinds to a halt. I finally got tired of this and figured out how to configure TextMate to automatically ignore these folders.

Go to TextMate’s Preferences -> Advanced -> Folder Pattern

Replace this default pattern:
!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$

with this pattern that adds an exclusion for folders named ‘build’ or ‘log’:
!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))|build|log$

2013 UPDATE: You can now download older version of Xcode here: https://developer.apple.com/downloads/index.action?name=Xcode

Every once in a while you have to compile an older project with an iPhone SDK you may no longer have installed. Apple removes links to the older versions even though the SDKs are still on their servers.

Please note that you need to be logged into your iPhone Developer Account

Update: Removed the older links that are no longer hosted on adcdownload.apple.com.
Update 2: Changed links from developer.apple.com/iphone to developer.apple.com/ios

iPhone OS 3.0 introduced Spotlight Search: Flick to the left and you can search through the apps you have installed as well as other things like contacts, calendars events, emails, songs and notes.

For apps the iPhone OS will look at the app name that you see under it’s icon. So typing ‘bird’ would find the Birdfeed app.

But the OS also looks at the name of the app as it appears in iTunes. Birdfeed’s name in the app store is “Birdfeed – A very nice Twitter client”, which is why Birdfeed shows up when you type ‘twitter’.

spotlight

When you download an app to your phone the .ipa file includes the actual app binary as well as an iTunesMetadata.plist file. This plist file contains the app’s name as it appears in iTunes.

Tweetie on the other hand doesn’t show up in the screen-shot above even though it is installed on the phone. Tweetie’s name in the app store is “Tweetie 2″ which doesn’t include the word ‘twitter’.

Follow us on Twitter

Sometimes it’s useful to quickly see all the subviews of an iPhone view.

Perhaps you’re debugging a problem in one of your views or trying to understand the inner workings of one of the built in views.

You can simply iterate over a view’s subviews, but then you won’t see subviews deeper than one level. You need a method that recursively walks the hierarchy.

Luckily Apple has already done this with an undocumented UIDebugging category on UIView that makes this very easy: recursiveDescription

At the gdb prompt in the Xcode debugger you can say:

p [[self view] recursiveDescription]

and instantly see a description of the entire view hierarchy.

Follow me on Twitter

Apple released an iPhone app for this year’s WWDC. You can download the app from the WWDC attendee site.

The instructions are to download the zip file, drag the app and the provisioning profile to iTunes then sync your phone.

If you’d like to install the WWDC app on a device that isn’t setup for iTunes syncing, then you can use Xcode instead of iTunes. Here are the steps:

1. Download the zip file. Expand it and you’ll see two files: WWDC09.app and a .mobileprovision file.

2. Launch Xcode and open the Organizer (Window -> Organizer)

3. Select your iPhone/iPod Touch in the organizer window.

4. In the Provisoning section click the + under the list of provision files and select the WWDC app’s provision file you downloaded.

5. In the Applications section click the + under the list of Applications and select the WWDC09.app you downloaded.

When Xcode is done, the WWDC09 app will be installed on your device.

When you show web content in a UIWebView, links that open a popup do nothing.

This makes sense. Since UIWebView is an embedded control in your app, there is no logical default for popups.

So how will users view those pages? The solution is to convert all popups to normal links before displaying the web page:

-(void) webViewDidFinishLoad:(UIWebView *)wv
{
    [wv stringByEvaluatingJavaScriptFromString:@"\
    links = document.getElementsByTagName('a');\
    for (i=0; i<links.length; i++) {\
        links[i].target = '_self';\
    }"];
}

Follow

Get every new post delivered to your Inbox.