ios - Serious Application Core Data Error Swift3 -


i trying data multiple apis , saving coredata database. earlier comes once in ten times. getting every time.

i have created dispatchgroup , trying hit api 1 one. below code.

 let group = dispatchgroup()      group.enter()     sharedfunctions.getcoursesessions {         print("course session done")         group.leave()     }     group.enter()     sharedfunctions.getcoursecontent {          print("course content done")         group.leave()     }      group.enter()     sharedfunctions.getcoursequiz {         print("course quiz done")         group.leave()     }      group.notify(queue: dispatchqueue.global(qos: .background)) {         print("all async calls run!")          dispatchqueue.main.async {             acprogresshud.shared.hidehud()               completrion()         }     } 

below fetching , saving data api

class func getcoursesessions(completion: @escaping () -> ()) {      let param = "module=getcoursesessions&userid=\(user.uid)&akey=\(user.akey)&schedule_course_id=\(user.schedulecourseid)"      sharedfunctions.callwebservices(url: urls.base_url, methodname: "post", parameters: param, istoken: false, tokenval: "", completion: { (jsondict) in          print(jsondict)          dispatchqueue.main.async {          if ((jsondict.value(forkey: "message") as! nsdictionary).value(forkey: "success") as! string) == "true" {             sharedglobalvariables.arraycoursesessions = (((jsondict.value(forkey: "message") anyobject).value(forkey: "data") anyobject).value(forkey: "result")) as! nsmutablearray             print(sharedglobalvariables.arraycoursesessions.count)             //   dispatchqueue.main.async {             sharedglobalvariables.loginbool = true             // reference app delegate             if #available(ios 10.0, *) {                  let appdelegate = uiapplication.shared.delegate as! appdelegate                 print(sharedglobalvariables.arraycoursesessions.count)                  j in 0...sharedglobalvariables.arraycoursesessions.count - 1 {                      let managedcontext = appdelegate.persistentcontainer.viewcontext                     let entity = nsentitydescription.entity(forentityname: "course_sessions", in: managedcontext)                      let coursesessionsscreen = course_sessions(entity: entity!, insertinto: managedcontext)                      if let arrdata = sharedglobalvariables.arraycoursesessions[j] as? nsdictionary {                           if let courseid = arrdata.value(forkey: "course_id") as? int16 {                              coursesessionsscreen.course_id = courseid                         }                          if let userid = arrdata.value(forkey: "user_id") as? int16 {                              coursesessionsscreen.user_id = userid                         }                           if let enablenextscreensequence = arrdata.value(forkey: "enable_nextscreen_sequence") as? int16 {                              coursesessionsscreen.enable_nextscreen_sequence = enablenextscreensequence                         }                     }                     {                         try managedcontext.save()                          //         getcoursesessionproperties()                      } catch let error nserror {                          print(error)                     }                 }              } else {                 // fallback on earlier versions             }              //}          }          completion()          }     })  } 

there no perticular place crash app crash. crash above methode passing apis.

getting error:

     error domain=nscocoaerrordomain code=132001 "(null)" userinfo={message=attempt recursively call -save: on context aborted, stack trace=( 0   coredata                            0x0000000111ff3892 -[nsmanagedobjectcontext save:] + 306 1   tuneem                              0x000000010f64046c _tfffzfc6tuneem15sharedfunctions26getcoursesessionpropertiesft10completionft_t__t_u_fcso12nsdictionaryt_u_ft_t_u_ft_t_ + 60 2   tuneem                              0x000000010f629197 _ttrxfo___xfdcb___ + 39 3   coredata                            0x000000011200cb52 developersubmittedblocktonsmanagedobjectcontextperform + 178 4   libdispatch.dylib                   0x000000011bf0205c _dispatch_client_callout + 8 5   libdispatch.dylib                   0x000000011bee094f _dispatch_queue_serial_drain + 221 6   libdispatch.dylib                   0x000000011bee1669 _dispatch_queue_invoke + 1084 7   libdispatch.dylib                   0x000000011bee1b32 _dispatch_queue_override_invoke + 654 8   libdispatch.dylib                   0x000000011bee3ec4 _dispatch_root_queue_drain + 634 9   libdispatch.dylib                   0x000000011bee3bef _dispatch_worker_thread3 + 123 10  libsystem_pthread.dylib             0x000000011c299712 _pthread_wqthread + 1299 11  libsystem_pthread.dylib             0x000000011c2991ed start_wqthread + 13 )}     error domain=nscocoaerrordomain code=132001 "(null)" userinfo=.      {message=attempt recursively call -save: on context aborted, stack trace=( 0   coredata                            0x0000000111ff3892 -[nsmanagedobjectcontext save:] + 306 1   tuneem                              0x000000010f64046c _tfffzfc6tuneem15sharedfunctions26getcoursesessionpropertiesft10completionft_t__t_u_fcso12nsdictionaryt_u_ft_t_u_ft_t_ + 60 2   tuneem                              0x000000010f629197 _ttrxfo___xfdcb___ + 39 3   coredata                            0x000000011200cb52 developersubmittedblocktonsmanagedobjectcontextperform + 178 4   libdispatch.dylib                   0x000000011bf0205c _dispatch_client_callout + 8 5   libdispatch.dylib                   0x000000011bee094f _dispatch_queue_serial_drain + 221 6   libdispatch.dylib                   0x000000011bee1669 _dispatch_queue_invoke + 1084 7   libdispatch.dylib                   0x000000011bee1b32 _dispatch_queue_override_invoke + 654 8   libdispatch.dylib                   0x000000011bee3ec4 _dispatch_root_queue_drain + 634 9   libdispatch.dylib                   0x000000011bee3bef _dispatch_worker_thread3 + 123 10  libsystem_pthread.dylib             0x000000011c299712 _pthread_wqthread + 1299 11  libsystem_pthread.dylib             0x000000011c2991ed start_wqthread + 13 

)}

trying solve last couple of days getting no idea, appreciate.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -