23 Nov 2008
FilePile: Finder for the iPhone
Back in August, I wrote my first iPhone app: FilePile. I had noticed that no apps on the App Store let me look at the iPhone's internal file structure, and the absence struck me as odd. I got around to submitting it on October 1, mainly because the NDA was lifted that day and Pragmatic Programmer's iPhone SDK book (released that day) included a similar file browser as sample code. Of course, the absence of such an application on the App Store was not any developer's oversight but explicitly forbidden by the iPhone SDK Agreement in 3.2(e), which I missed, and so FilePile was rightfully rejected on October 12. (Kudos to Apple for reviewing submitted apps at 10am on a Sunday.) I resubmitted it that day restricting its access to its own sandbox, but haven't heard back about it. Not a huge loss. An app whose sole purpose is browsing itself isn't very interesting.
So, I'm just releasing the source code, as it's only interesting to developers. FilePile was so straight-forward to code because Apple includes many standard APIs in the SDK, like NSFileManager. Just as it provides an API to access my Mac's file structure, the class allowed me to delve into the iPhone's file structure. The app provides a unique interface to let the user know where they are in the file structure, illustrated in the screenshot below. Clicking on a file shows a preview of it, either as text or an image thumbnail, and a list of its available attributes; attributes are easier to see in landscape mode. Check out these interesting paths:
- App Store Applications: /private/var/mobile/Applications (Until 2.1, these were all readable.)
- Camera Photos: /private/var/mobile/Media/DCIM
- Carrier Bundles: /System/Library/Carrier Bundles
One difficulty I had was supporting image preview because of the memory footprint. Previewing images in the Simulator is trivial in terms of memory, but the iPhone's environment required I manage the memory better. It was this path that led me to find the undocumented UIApplicationMemoryWarningNotification notification; using that allowed me to trigger low memory warnings in my application on the iPhone without actually running out of memory. Trying to debug a low memory condition on the iPhone with Instruments is extremely difficult.