I am getting this compiler error in my code and I can\'t figure out why:
:0: error: unable to execute command: Segmentation fault: 11
I am getting this same error when I try to extend NSArray
to have a foreach
method:
extension NSArray {
func foreach(f: (AnyObject -> ())) {
for elem in self {
f(elem)
}
}
}
It would appear that extending NSArray with func that takes a function argument will cause the same problems. I worked around the issue by defining a forEachInArray
function that takes the NSArray
as an argument:
func forEachInArray(array: NSArray, f: (AnyObject -> ())) {
for elem in array {
f(elem)
}
}