Re: How to wait for methods with result/completion blocks to finish?
Re: How to wait for methods with result/completion blocks to finish?
- Subject: Re: How to wait for methods with result/completion blocks to finish?
- From: Chris Markle <email@hidden>
- Date: Tue, 08 Mar 2011 13:44:03 -0800
Matt, Kyle,
Thanks for the guidance and pointers to other doc. I am having trouble
wrapping my head around the asynch patterns, especially since I am
working with a code base that I inherited that is not doing a good job
of leveraging these patterns.
There are two cases (at least) in that app (which uploads images and
videos from the Photo Library or Camera using a proprietary protocol)
where it seems like we need to "wait". Maybe you can help me mentally
refactor these two...
1. Camera used to take picture or video (UIImagePickerController).
Want to save image that was taken to the camera roll like happens with
the camera app. That saving process starts when the user returns from
the camera. If they then go to the Photo Library (again with
UIImagePickerController), we don't let them do that until the image is
fully saved since we want them to be able to see them image in the
library that they just shot. So when they tap the "photo library"
button, we (as Kyle said) "throwing up a modal 'please wait' UI" until
the save to photo library function is completed, at which point we
show the photo library.
2. When all the picture taking or choosing from the library choosing
has happened, and the user ultimately has picked an image/video to
upload, they press "upload". If it's a video, we have the file already
that we need to transfer. But if it's an image we would like to get
the JPEG representation (via ALAsset / ALAssetRepresentation) into a
file so that we can transfer that file (the uploader system is
file-based). That's where some form of that code with the resultBlock
from my original post comes into play. It has the resultBlock that
returns the asset and I need to wait for that block to complete so
that I have the JPEG representation available that I can then put into
a file to transfer.
Any thoughts about how I can adjust my thinking and the app's design
to deal with these cases would help me understand this better.
Thanks in advance.
Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden