views:

36

answers:

2

I have an core data app that stores strings and a couple of images. I would like users to be able to send entries to each other via email (like Apple's Contacts app).

I have created a url scheme that exports/imports all the strings, but the image data is a tough one.

Any help or point in the right direction would be greatly appreciated. Thanks

+1  A: 

If the images aren't too huge, you could put the data in the URL, Base64 encoded. If they're too big for that, you might need to figure out some intermediate storage, like uploading them to your server from the sender, and including some ID in the URL that will allow your app to download the image on the receiving side.

Sixten Otto
Base64 was the trick. It was a bit of an education but I was able to encode a couple of pictures and put them in a url scheme. Works great. Thanks
Sam
+1  A: 

The iPhone mail API supports adding an element to the email that you can use to embed the image as an attachment. The following lines of code will add the image to an email:

NSData *imageData = UIImageJPEGRepresentation(myImage, 0.7);
[userSubmitCompose addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"image.jpg"];
Marcus S. Zarra
Very true. When the recipient gets the email, how does the image get into their copy of the app? (I assume that that's the reason why the question talks about URL schemes at all.)
Sixten Otto
Can I then have the url scheme import these attachments?
Sam
Ahh I missed the import point. The URL scheme with Base64 encoding is the other option or posting the image somewhere like twitpic or your own server and pass around that url included in your link.Personally I would store the image in the cloud (like S3) and the retrieve it on the other end instead of trusting email URLs.
Marcus S. Zarra
Base64 was the trick. It was a bit of an education but I was able to encode a couple of pictures and put them in a url scheme. Works great. Thanks
Sam