I have created a seperate class to handle loading data from a SqlServer. Right now I pass a search term to the object and it searches for the items in a database.
If it finds more than one item it needs to present a modalviewcontroller. The problem is that this is a NSObject and doesn’t know about presenting modal views.
How can I present a modalviewcontroller from a NSObject?
Try to delegate presenting the modal to a view controller – either by posting notifications on duplicates (gives you flexibility in which view controller presents) or defining a delegate protocol. This will keep your model separate from your view, preserving the MVC architecture of your app.
EDIT: using blocks for delegation is a fine approach in my view. I would just adjust your API to take a block to be performed in case of a duplicate, and have your modal take another block to handle the selection from many. That will probably give you maximum flexibility.
EDIT2: Based on understanding of your current API, I’d recommend this:
Furthermore I’d design your modal view controller to take a completion block as well.