Why can't I return an object from my block?

前端 未结 3 1483
春和景丽
春和景丽 2020-12-11 13:24

I\'m trying to return a NSMutableArray from my block in my method, but when I add the line return [responseString JSONValue];, I get some compiler

3条回答
  •  独厮守ぢ
    2020-12-11 13:49

    What are you expecting returning an object to do? Presumably the completion block that you hand to ASIFormDataRequest is declared as void (^)() (or dispatch_block or some other typedef which evaluates to void (^)()). Given this, the code calling the block isn't expecting a return value. It would be like implementing a method declared - (void)foo and trying to return an object from that; it just doesn't make sense.

    Edit: After re-reading your code, I expect what you're really trying to do is returning a value from -getTodayData:. However you're executing an asynchronous request. The method -getTodayData: has already returned long before your block is executed.

提交回复
热议问题