1
votes

By Apple Documentation

Main -

For non-concurrent operations, you typically override only one method:

main

Start -

When you add an operation to an operation queue, the queue ignores the value of the asynchronous property and always calls the start method from a separate thread. Therefore, if you always run operations by adding them to an operation queue, there is no reason to make them asynchronous.

If i have to execute the code of Alamofire which already uses a operation queue and is asynchronous. Where should i write the code (Main or Start) to call Alamofire request.?

2
Have you read the extensive descriptions of those two functions in the documentation for NSOperation? If so, what exactly aren't you sure about?rmaddy
I made the question specific to my needs. ThanksRahul Katariya

2 Answers

1
votes

Maybe I did not grab the point of your answer, but, if you need to wrap Alamofire in your custom operation, you must create an asynchronous NSOperation.

You can find a very good example of this in this Github repo.

The key point are:

  • override the asynchronous property returning true
  • override the start method
  • take control of the isExecuting and isFinished properties in order to change the state of the operation
-1
votes

Well you could implement both Main and Start as one line functions that each call MyRealProcessingFunction which does your real work.