I have been trying various solutions to get an updated value of handler
from methodTwo
and methodThree
. The code starts with methodOne()
, followed by methodTwo()
. How to approach this puzzle?
These methods are declared inside a static library. And its reference implementation i.e. a SampleApp.xcodeproj is calling methodOne()
, which is exposed in the header files of the static library.
I have looked into KVO and NSNotificationCenter, but it seems that the direction is not correct.
-(void)methodOne: completion:(void (^)(BOOL success))handler {
// Step 1
// Open view controller from PayPal-iOS-SDK
// BOOL = handlerStatus;
if (handler != nil)
handler(handlerStatus);
}
-(void)methodTwo {
// Step 2
// Delegate method from PayPal-iOS-SDK (executed after methodOne())
// Generates a code which needs to be sent to server to get success/fail
// Call methodThree to update handlerStatus
}
-(NSString*) methodThree {
// Step 3
// Returns success/fail i.e. handler value
// Network call (sending code to server)
}
Update
I wanted to use a completion handler, since that's not working. I have to resolve this issue by using delegation as a messaging protocol.