Xcode swift failed with exit code 254

前端 未结 7 2379
灰色年华
灰色年华 2021-02-07 14:14

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


        
7条回答
  •  不知归路
    2021-02-07 14:45

    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)
        }
    }
    

提交回复
热议问题