-2

When debugging a crash with crash message Thread 1: Fatal error: NSArray element failed to match the Swift Array Element type. I passing a list to a function: [MyObject] but the debugger in debug window area of Xcode show me:

list([Project.MyObject])
  _buffer (_ArrayBuffer<Project.MyObject>)
     _storage(_ArrayBridgeStorage)
       rawValue = (Bultin.BridgeObject)

Update: Instate of create and passing list of MyObject from XCTestCase class. I move the method which create list of MyObject into my logic class. The test is Success. So I am sure the crash relate to cocoa bug. But still don't know how to work around to fix it.

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
lee
  • 7,955
  • 8
  • 44
  • 60

1 Answers1

0

The crash has nothing to do with what _ArrayBuffer is. The crash is because you obtained an NSArray from Cocoa / Objective-C where an array of MyObject was expected, and something in the NSArray was not a MyObject.

That does happen now and again, mostly because of bugs in Cocoa itself. (I give an example here: UIDynamicAnimator items(in:) crashes in iOS 11.) Unfortunately you showed no code of yours at all, so how it happened in your case is anyone's guess.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Hi , i am facing specialized _ArrayBuffer._getElementSlowPath(Int) issue in some of device (mostly in iOS 11 and some of 10.0) randomly (Happened sometimes). My project is with swift 3.0 and i'm using firebase crashlytics with pods. Does my problems also related to cocoa itself. Fatal Exception: NSRangeException 0 CoreFoundation 0x18a74a1c0 __exceptionPreprocess 1 libobjc.A.dylib 0x18918455c objc_exception_throw 2 CoreFoundation 0x18a6b53dc __CFArrayGetCallBacks 3 USU ACCESS 0x10017174c specialized _ArrayBuffer._getElementSlowPath(Int) -> AnyObject (CalendarView.swift) – Jamshed Alam Aug 19 '18 at 05:20
  • Using Xcode 8.3.3 (swift 3.0). Is it related to this ? Do i must need upgrade Xcode and swift version to get rid off this ? – Jamshed Alam Aug 19 '18 at 06:51