ios - Am I opening my database the right way? -


I have a database manager class that works to create and open DB in my app, and when it is needed Then the 'context' is handed over. The problem is that openWithCompletionHandler is async, so the OpenDatabase call returns immediately, so my initial view controller is trying to get data from a database that has not been opened.

My solution is to pass the initial VC by the OpenDatabase method and call it back to the VC in the code block block. Therefore, my initial VC basically calls the caller to open the database manager, then sits and waits, until the call is returned, then the data is required to be displayed.

It works fine and there is no delay in showing in the data.

Is there a normal way to do this? I want to learn the best method instead of jury rigging which works, I tried to read various searches and Apple docs and could not find the answer. If I see something clearly in the document, please tell me there.

Thank you!

"Is there a normal way to do this?" Yes. This is what happens when some is asynchronous is a complexity because the object A which is the asynchronous thing is not an object B, which is done asynchronous work, then it needs to be reloaded, but you need to reload the object A Has solved with beauty. This is not really the case, eg separate NSURL session calls back its representative.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -