ios - fetchRequest is return empty array -


I am trying to get the request from my DB but I am getting zero in the response. If I use this method then I get "sometimes" values ​​(I know that I have data in DB). I think it is related to threads in some way or I am using multi-context. So my question is basically generic.

  1. If I am saving some data in specific MOC then we call it MOC1 and then want to get the data that I just save .. Any MOC ? (Assuming I could get with child and save parents and I can see the change dB)

  2. NSPrivateQueueConcurrencyType that if I use I MOC NSMainQueueConcurrencyType MOC Save data with? And the opposite direction ..?

  3. Can I bring data to the background thread or do I need to bring it to the main thread?

  4. What is the connection between the main thread and the NSMainQueueConcurrencyType

  5. What is the connection between the background thread and NSPrivateQueueConcurrencyType Thanks,

    Update:

    The thing is that I bring some unit and some flag changes. I save my method to save it use:

      - (minus) saveDataToDBWithCompletionWithManagedObjectContext: (NSManagedObjectContext *) managedObjectContext withCompletion: (zero (^) (BOOL successful, NSError * error)) complete {if (ManagedObjectContext! = null ) {[ManagedObjectCo Ntext Display Block Endwhit: ^ {NSError * errorMsg = noil; If ([Managed Object Context Change] & amp;! [Managed Object Contact Contact: & amp; Error Message]) {// Some actual error handling can not save NSLog (@ "Background Reference, Error% @,% @, Error message, [ErrorMsg userInfo]; if (complete) {complete (NO, errorMsg);}} and (if (complete) {complete (yes, zero);}}}];} and (if (completion) { Complete (NO, NULL);}}  

    }

    Obtain NSManagedObjectContext to this method, and save it to the related NSManagedObjectContext. (Bool) toDoS ync WithCompletion: (void (^) (BOOL successful, NSError * error)) complete {NSError * ERRORMSG = Zero - (minus) saveMasterDataToDBWithSync

     : If I save to keep my boss; if (! self.masterManagedObjectContext = null) {if ([self.masterManagedObjectContext hasChanges] & amp; & amp ;! [self.masterManagedObjectContext save: when & amp; ERRORMSG]) {if (perfection) {complete (no, ERRORMSG); }} And {if (toDoSync} {// sync with parse} if (full) {complete (yes, zero);}}} and (if (complete) {complete (not, zero); }}   

    }

    When I check my DB, the data is there! But when I try to bring it, then I can not see anything.

  1. Yes but to inform MOC about the changes you made One way to find out. Do this by saving a child / original reference ( parentContext ) by saving the continuously Story Coordinator or by using mergeChangesFromContextDidSaveNotification to merge the changes You can.

  2. You may want to save in any case. Like # 1.

  3. As long as you use the thread / queue associated with this MOC, you can get whatever thread you want. You can do this by using performBlock or just making sure that you have a NSMainQueueConcurrencyType running and calling Fetch from the main thread.

  4. NSMainQueueConcurrencyType should run only on the main thread.

  5. NSPrivateQueueConcurrencyType has your own personal queue to use performBlock to run a fetch on that queue.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -