Forcing an iPhone or iPod touch into recovery mode
When Apple released iPhone OS 2.0.1, iTunes installed the update on my iPhone without any trouble, but it refused to update my iPod touch, insisting that version 2.0 was the latest. I tried restoring it but got an error message saying "resource not available" (or something like that).
I thought the problem might be that I had been using the iPod touch for application development and therefore was running the final iPhone OS 2.0 beta (build 5A345) instead of the "official" 2.0 release. I even tried purchasing the official update, but for some reason I was unable to download it. (Fortunately, an iTunes Store support person refunded my $10.)
As it turns out, I wasn't the only one having this problem, and one helpful forum user eventually discovered a solution, which is to force the device into recovery mode. By following Apple's instructions, I successfully updated my iPod touch to 2.0.1 (although I didn't try restoring any backed-up data, since I use the device only for development and don't sync it with iTunes). This procedure should work for iPhones, too, so if you've been unable to update your device by the usual methods, give this a shot.
Tags: apple, iphone
Wed, 13 Aug 2008 16:22 UTC
Disabling Leopard’s ridiculous “Are you sure you want to open it?” dialogues
Turns out it's easy. Just create a text file called com.apple.DownloadAssessment.plist under Library/Preferences in your home directory, with the following content:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSRiskCategoryNeutral</key>
<dict>
<key>LSRiskCategoryContentTypes</key>
<array>
<string>public.item</string>
</array>
</dict>
</dict>
</plist>
Then log out and back in. Done.
For details of how this works, see the following:
Tags: apple
Tue, 06 May 2008 23:03 UTC
Creating iPhone-compatible movies with PyObjC and QTKit
As part of some general messing around with PyObjC and QTKit, I wrote a short script for converting a movie (anything readable by QuickTime) into an iPhone-compatible format. It's basically a Python version of an Objective-C example from Apple.
The code:
#!/usr/bin/python
import struct
import QTKit
class QuickTimeError(Exception):
@classmethod
def from_nserror(cls, nserror):
return cls(nserror.userInfo()['NSLocalizedDescription'])
def long_from_string(s):
return struct.unpack('>l', s)[0]
def convert_for_iphone(infile, outfile):
in_attrs = {
'QTMovieFileNameAttribute': unicode(infile),
'QTMovieOpenAsyncOKAttribute': False,
'QTMovieApertureModeAttribute': QTKit.QTMovieApertureModeClean,
'QTMovieIsActiveAttribute': True,
}
movie, error = QTKit.QTMovie.movieWithAttributes_error_(in_attrs, None)
if movie is None:
raise QuickTimeError.from_nserror(error)
out_attrs = {
'QTMovieExport': True,
'QTMovieExportType': long_from_string('M4VP'),
}
status, error = movie.writeToFile_withAttributes_error_(unicode(outfile),
out_attrs,
None)
if not status:
raise QuickTimeError.from_nserror(error)
if __name__ == '__main__':
import sys
infile = sys.argv[1]
outfile = sys.argv[2]
convert_for_iphone(infile, outfile)
To use it:
$ ./convert_for_iphone infile outfile
I've only tested it with the system Python under Leopard. While the script isn't all that useful in itself, it may serve as a helpful example to someone. Sure the hell beats doing the same job with AppleScript.
Tags: apple, iphone, pyobjc, python, qtkit
Wed, 20 Feb 2008 00:11 UTC