I am writing a simple application using the iPhone iPhone SDK. The Facebook code is mostly asynchronous, I start the operation and get the response asynchronously in the delegate call:
- (void) doSomething { [FBSomething startOperationWithDelegate:self]; } - (void) fbOperationFinished: (FBSomething*) operation {โฆ}
Quite often, there are more instances of a given operation (say FBRequest ) that use the same callback. This means that I have to put a conditional clause in the callback handler to find out which of these operations has completed.
This leads to a messy, sort of โasynchronous spygen code,โ because the code is full of conventions and it is almost impossible to see the logic of the program stream. Is there a better way to write such code? (Itโs a shame that we donโt have blocks on the iPhone.) I thought about introducing a simple state machine, but Im not sure if this will help.
source share