与EXC_BAD_ACCESS KERN_INVALID_ADDRESS崩溃

时间:2017-10-09 13:57:05

标签: ios swift crash exc-bad-access

当委托被召唤时,崩溃时:EXC_BAD_ACCESS KERN_INVALID_ADDRESS

我无法理解是什么造成的..

   func updateAnnotationLocation(_ annotation:Annotation,isNewAction:Bool){
        self.updateAnnotationOnView(annotation)
        if annotation.type == .Note {
            (annotation as! NoteAnnotation).updateTextViewFrame()
        }
        var index = 0
        while index<self.annotations.count {
            if annotation.id == self.annotations[index].id {
                if isNewAction {
                    let action = AnnotationAction(type: AnnotationActionType.UpdateAnnotationLocation, annotationBeforeAction: self.annotations[index],annotationAfterAction: annotation)
                    self.addActionToActionsList(action)
                }
                self.annotations[index] = annotation
                if let selectedAnnotation = self.selectedAnnotation {
                    if annotation.id == selectedAnnotation.id {
                        self.selectedAnnotation = annotation
                    }
                }
                break
            }
            index += 1
        }

    }

崩溃: 如果annotation.id == self.annotations [index] .id

堆栈跟踪:

#0 Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000020
0   libobjc.A.dylib objc_retain + 16
1   FielNoteAnnotation.swift line 0 initializeWithCopy for NoteAnnotation
2    AnnotationViewController.swift line 746 AnnotationsViewController.updateAnnotationLocation(_:isNewAction:)
3    AnnotationViewController.swift line 915 AnnotationsViewController.undo()
4    AnnotationViewController.swift line 513 AnnotationsViewController.undo(_:)
5    AnnotationViewController.swift line 0 @objc AnnotationsViewController.undo(_:)

0 个答案:

没有答案