iostwitterios5twrequest

How to return a value from from a TWRequestHandler completion handler in iOS?


I'm trying to use the new twitter classes in ios5, but am having problems because of the completion handlers. How can I make a request in a method and have that return a value of something from the completion handler?

- (NSString) myMethod {

    TWRequest *request = ...

    [request performRequestWithHandler:

         ^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {

             myString = ...

         }];

     return myString
}

Solution

  • Your best bet would be to call another method or do whatever you need to do when its completed, I wouldn't recommend returning a value in there.