I am writing an iPhone application that allows you to view images in one view and create them in another.
In the view that creates the image, the image will be written to the document folder using the following code (when you click the button to reject the view):
[UIImagePNGRepresentation(image) writeToFile:path atomically:YES]
An image will be loaded in the browser using:
UIImage *image = [UIImage imageWithContentsOfFile:path];
Now it works fine 9 out of 10 times. 1 out of 10 the image is not written completely before uploading it so that the bottom half is black. Everything will be recorded in the end - if I reload the image in the browser, the full image will be shown. I thought that these things would always be consistent within the same thread.
Can I do something to prevent this behavior?
Now Iām thinking about transferring the newly created image back to the browser, but this seems like a hack since the browser displays all of your previously created images.
source share