执行被中断,原因:信号 SIGABRT

问题描述

我正在根据我正在学习的教程在操场上工作,并且我正在使用他们给我的文件(没有更改它)。不幸的是,我收到此错误“执行被中断,原因:信号 SIGABRT”。

这是我的代码,错误出现在 people.filtered(using: allAge61)

class APerson: NSObject {    // Must inherit from NSObject or NSPredicate will fail at runtime
    let name: String
    let age: Int 
    
    init(name: String,age: Int) {
        self.name = name
        self.age = age
    }
    
    // description lets you pretty print this class' instances in the sidebar
    override var description: String {
        return self.name + " - \(self.age) years old"
    }
}

/*:

and a bunch of People

*/

let groucho = APerson(name: "Groucho",age: 50)
let chicco  = APerson(name: "Chicco",age: 61)
let harpo   = APerson(name: "Harpo",age: 45)
let zeppo   = APerson(name: "Zeppo",age: 61)

let people: NSArray = [groucho,chicco,harpo,zeppo]
// using a NSArray here because predicates work with them,not with regular Swift Arrays

/*:

we can get __all people of age == 61__ with a simple predicate

*/

let allAge61 = NSPredicate(format: "age = 61")

people.filtered(using: allAge61)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)