c++ - dispatch_async crash on iOS device only, why? -


my application crashing @ below code point. on device, on simulator application works fine.

dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0)                , ^(void) {                     // time consuming things here                    // perform task here required run on separate thread/queue                     cppclass& ptr = cppclass::getinstance();                    ptr.synctrackingdata([newobject primaryid]);                     dispatch_async(dispatch_get_main_queue(), ^{                         // after completion of thread tasks                        // things here in main queue                        // example: update ui controls, etc.                         nslog(@" synchronization done ");                    });                }); 

here app flow method execution:

  • getting data in json response web-service (using libcurl)
  • parsing data , creating model objects
  • once model object created, requires synchronize data local db well. hence, calling synctrackingdata method parameter - handles scenario.

regarding synctrackingdata method: method available in cpp class file, creating new thread on there , using thread, application data getting stored local database file (in document directory).

we using separate thread method - because have model objects, view data can displayed , database filling can done background process.

any guesses reason.

have looked compiler warnings on code?

if there no compiler warnings on code, sprinkle more nslog statements @ different points in code. run app on device while device connected machine that's running xcode. watch console output while app running.

also, can view console output after fact -- when device connected, bring organizer window , click on "device logs" device.


Comments