Now here’s a snippet which will probably be a surprise to you: How to write a file to be shared between applications from within your sandbox! Yes, we said “from within your sandbox”. No, really, we did. And simple once you know how, of course — here it is:
BOOL result = [@"malc" writeToFile:@"/private/var/mobile/Media/DCIM/
malc.txt" atomically:YES];
Why does that magic incantantion work? Well, if you’re a particularly clever spark, it occurred to you that
I discovered this when I realised that the UIImagePickerController writes camera photos to that folder too, so your app must have write access, which it does
![]()
Yes, when you think about it, indeed it must, mustn’t it now? And whilst I’m quite sure from Apple’s perspective this counts as unsupported, at first glance it doesn’t appear to be actually illegal by any currently published standards … so assuming that you put in appropriate writability verification in case the picker’s path changes or they get pickier (heh) about allowing access in future, this seems like a most excellent way to approach the problem of application data transfer/sharing on the device!
h/t: iphonesdk!

1 Response to “Snippet: Data Sharing”
Leave a Reply