iOS doesn't support cross-store copies yet EKEvent

Viewed 662

I am getting this NSInternalInconsistencyException error while saving EKEvent on Xcode 9, iOS11.

do {
     try eventStore.saveEvent(newEvent, span: .ThisEvent, commit: true)        
   } catch {

   }

Error:

Fatal Exception: NSInternalInconsistencyException iOS doesn't support cross-store copies yet.

2 Answers

Whenever you are assigning any value to other object means copying one value to other value, so it was sometime sending exception.

In my case:

if(orginalEvent.structuredLocation != nil){
            newEvent.structuredLocation = orginalEvent.structuredLocation
        }

So, i have replaced with below:

if(orginalEvent.structuredLocation != nil){
            if orginalEvent.structuredLocation!.title.characters.count > 0{

                let location = EKStructuredLocation(title: orginalEvent.structuredLocation!.title)
                if(orginalEvent.structuredLocation?.geoLocation != nil){
                    location.geoLocation = CLLocation(latitude: (orginalEvent.structuredLocation?.geoLocation?.coordinate.latitude)!, longitude:  (orginalEvent.structuredLocation?.geoLocation?.coordinate.longitude)!)
                }

                newEvent.structuredLocation = location
            }

        }

So, it is working now.

Don't create and use new EKEventStore(). Just use existing EKEventStore instance.

Related