I currently have a UIViewController and an NSObject class.
What do I want to do to tell NSObject class to do one thing and then after implementing it, tell the UIViewController
I call the object to do such a thing Like I am:
[fooObject performActionWithDelegate: self]; The PerformActionWithDelegate function takes the representative of the UIViewcontroller to basically callback only.
- (zero) performActionWithDelegate: (id) d {// times the FooObject header file declared in // id bar; [Bar set deliite: D]; [BarKelback]; } Where performCallback is a simple NSLog () - Status in UIViewController: - (Zero) showcaseback {nslog (@ "callback successfully done"); { Now, I should do this. My first guess is that this is not the best way to solve this problem.
The full scope of the problem is that fooObject is a An httppost for webservice is considered to update one of its properties and then inform the UIIVIC controller if the operation was successful or not
How do I get it?
Any suggestions and / or signals will be highly appreciated!
Thanks in advance
Edit: The real problem is that fooObject is not showing the callback.
It is not clear what you are trying to accomplish. What you're doing seems related to two different design patterns:
- Representative
- Asynchronous callback
Representative: If you have any reason to separate some UIIUIUIUIUIUIUutulator functionality into another object, then you will use a representative. Instead the UIViewController asks something else to do it instead. This code is usually used for reuse so that you can serve the same UIViewController in different cases and change only the representative to change its behavior. asynchronous callback: This will be notified when you are performing other things in the background to be in operation and then by calling a method of your object upon completion of the operation. You can do this without involving other things. In your case, why do you want to have an HTTP post for a web service outside of our UIUUUTOuteller? Do you want to separate the network code from the UI code? In this case, you do not really need a representative, just call the method from your UIWUUUUUL controller to another object and when it returns, it is done. It can return any results you may need in other parameters. Returning the value by setting the properties on the calling object is not usually a very good design even if you do so, then UIViewController is not really a "representative".
On the other hand if you are concerned about blocking the main thread, while the HTTP post is in the process, then you want to use something like the Asynchronous Callback, the easiest way to do this is to use Conceptually, you can do something like this:
send_sync (send_gate_global_que (dispatch_QUEUE_PRIORITY_DEFAULT, 0), ^ {[self-openHHTPPost]; dispatch_acic (dispatch_gate_man_clue ()), {{self Long HTTP Post Doon};}); }); This will call doLongHTTPPost in the background and after some time it will call longHTTPPostDone on the main thread Where UI is safe to take actions.
Comments
Post a Comment