I'm still struggling with trying to match types against empty arrays. In this case, I have an array that was originally created like this:
var x: [X] = [] // X is a struct
This empty array is passed around as an 'Any' parameter:
func jValueForPValue (pValue: Any) -> AnyObject { …
and eventually I try to test if the parameter is an array:
if let pArray = pValue as? [Any] { …
This test fails. If I set a breakpoint just after it fails, I get this:
(lldb) p pValue
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x80000007).
The process has been returned to the state before expression evaluation.
(lldb) frame v pValue
(Any) pValue = {
payload_data_0 = 0x000000010247efa0 -> 0x000000010081cd70 _swiftEmptyArrayStorage
payload_data_1 = 0x000000010247efa0 -> 0x000000010081cd70 _swiftEmptyArrayStorage
payload_data_2 = 0x000000010247efa0 -> 0x000000010081cd70 _swiftEmptyArrayStorage
instance_type = 0x000000010247efa0 -> 0x000000010081cd70 _swiftEmptyArrayStorage
}
I don't know what this means, or what to do about it.
The interesting thing is that the test for array succeeds at least sometimes, and in the case I looked at, the array was the empty one that was discussed in a previous thread, originally created inside a dictionary like this:
["key": [Any] ()]
Since an array passed as 'pValue' can in fact be an array of anything (Ints, Strings, structs, classes, collections), I don't know what test to use. Anyone got any ideas?