I am having trouble checking a value in a mutlidimensional array.
I am creating an array within an array with 3 arrays inside.
The array is called profilerdata, the variable "key" is a string so it should just be three stings in these arrays.
The array in my log as a SwiftDeferredNSArray which I think is the first problem as I have read this is a non mutable array.
var newKeyArray = [[key],[String](),[""]]
for thing in dataArray as! [[String: AnyObject]] {
newKeyArray[1].append("0")
}
print(newKeyArray)
profilerData.append(newKeyArray as AnyObject)
I then try and read the value in the array like so:
var n = 1
while n <= elementArray.count {
if profilerData[n][0] as! String == headertitle {
print("it matches")
} else {
print("it does not match")
}
n += 1
}
The variable "headertitle" is a string too but when this runs I get an error:
Could not cast value of type 'Swift._SwiftDeferredNSArray' (0x104ce8040) to 'NSString' (0x101f97c60).
This error is occuring on this line
if profilerData[n][0] as! String == headertitle {
Any help much appreciated,
p.s. Please explain quite simply as I'm new to Swift.
newKeyArraytoAnyObject? Also, can you quote the error message more accurately and explain what line it occurs on?