On 10 May 2012, at 22:55, Ken Thomases wrote:
As to whether it's OK/recommended, that depends. Why are you doing
this? The caller of that method may be very surprised if it's
asynchronous.
No the caller is always expecting it to be ASync. It's just that I
have to use a library that uses a delegate Object/selector passed to
it and calls it back when the task has finished. This is ok and
wanted most of the time,but now we have added a whole load of other
functionality and some of it needs to be run in a certain order
depending on the responses. Sort of like this
myResultObjectA = nil
myResultObjectB = nil
myResultObjectC = nil
myResultObjectD = nil
myResultObjectE = nil
myResultObjectA = doTaskA
if (myResultObjectA.someProperty == 0)
myResultObjectB = doTaskBWithSomePropertiesOf: myResultObjectA
else if (myResultObjectA.someProperty == 1)
myResultObjectC = doTaskCWithSomePropertiesOf: myResultObjectA
else
ERROR;
if (myResultObjectB == nil)
myResultObjectD = doTaskDWithSomePropertiesOf: myResultObjectB
else
myResultObjectD = doTaskDWithSomePropertiesOf: myResultObjectC
myResultObjectE = doTaskDWithSomePropertiesOf: myResultObjectA
andPropertiesOf: myResultObjectD
return myResultObjectE
All the doTask methods are ASync,
The actual implementation I am working with handles the doTaskXXX
calls by passing in Delegate Object and a Completion Selector to the
method. When you try to implement the above in that manner , it
creates a rats nest of methods which resembles out of control goto's!
It makes more sense to be able to have all the code in one method.
Cheers
Dave
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com