I have to carry out a series of download and database write operations in my app. I am using the NSOperation
and NSOperationQueue
for the same.
This is application scenario:
- Fetch all postcodes from a place.
- For each postcode fetch all houses.
- For each house fetch inhabitant details
As said, I have defined an NSOperation
for each task. In first case (Task1), I am sending a request to server to fetch all postcodes. The delegate within the NSOperation
will receive the data. This data is then written to database. The database operation is defined in a different class. From NSOperation
class I am making a call to the write function defined in database class.
My question is whether the database write operation occur in main thread or in a background thread? As I was calling it within a NSOperation
I was expecting it to run in a different thread (Not MainThread) as the NSOperation
. Can someone please explain this scenario while dealing with NSOperation
and NSOperationQueue
.
NSOperation
norNSOperationQueue
contain delegate properties. – Jeffery Thomas