ios - NSProxy and forwardInvocation: invoke called within a block causes nil return value -
I am using a Some background information: I want to capture API calls so that I can check every time if I need to refresh my authentication token if so, then I just refresh it before The method parameters ( A few simple codes: Yes, so my blocks and other parameters are not lost ( Everything works fine till now - but: return value is always a Any hint? suggestion? Update @ Reply to Clash of the Answer: The problem is that the return value is type When your call is completed, to pass the result: Where He said, I have been trying to solve some experiences with almost absolutely problems (token based authorization) I suggest that the approach of this problem How it's reached, it can offer some ideas for alternative implementations. NSProxy subclass and
forwardInvocation: For my backend API object (a shared frequency) to capture calls
invocation of) are blocked.
- (zero) forwarded charge: (nsiivation *) invocation {[invoice setagraph: self ali api]; [Arguments to keep the invitation]; // Refresh Call and after successfully refreshing // successfully refresh after record. (Authenticity Reproduction) {[Self. Real API refresh: withblock: ^ (NSObact * some object) {[Inoculation avalicious target: self-ali API]; }]; } // Otherwise we only want to immediately greet {{invention} next to it. Goal: AutoApi]; } Return; } Calling
retainingArguments already due to the last execution of
invokeWithTarget:
refresh with block: calls an async API).
zero when
invokeWithTarget: is done within the refresh block is there any way to retain the return value (eg logic)?
NSURLSessionDataTask That I use to show an activity indicator) which I read directly after calling. But the proxy does not immediately send calls, so the return value is not there - of course (I was blind). What would be possible solutions? Can I return the placeholder value or how the method is brought when I can call it as collar, can I get the return value later?
if (authentication is refreshed) {{self.realAPI fresh with block: ^ (NSObject * someObject) {NSURLSessionDataTask * resultTask = zero; [Greeting call statement: Target. [Invitation getReturnValue: and resultsTest]; If (complete! = Zero) {complete (resultTask); }}]; }
is complete () is a block that takes the
NSURLSessionDataTask as the parameter used as a callback That is, whatever you are trying to do is well suited ("when I am doing this, I do it") Ideally, it would pass in the above method - but it can be passed on to the
Forwarding frequency is: , which is a bit more ... challenging. You can set it as a property on this proxy object and you can read it from there.
addDataTask: which you can call instead of your block, which can "turn off the responsibilities for", another way is to expand the UIIP with a class or informal protocol. I've just added a Data Reichizer, most likely that the representative of the application (and you can increase the UIiproduction Delegate protocol to handle a new method,
application: didAddDataTask: ) It looks like your data task and activity indicators are application-level concerns, which can make it a good fit.
Comments
Post a Comment