从初始化程序

时间:2017-05-28 19:46:01

标签: ios swift

试图添加一堆对象。这有什么不对?在所有路径上都没有调用self.init吗?

    convenience init(testdata: Bool = false) {
    if testdata {
        let expenses = ["Housing", "Cell Phone", "Utilities", "Auto Insurance","Food", "Netflix","Internet"];
        let prices = [600,90,50,106,240,9,60];

        for i in 0..<6 {
            let expense = expenses[i];
            let valueInDollars = prices[i];
            self.init(expense: expense, valueInDollars: valueInDollars);
        }
    } else {
        self.init(expense: "", valueInDollars: 0);
    }
} <-- Error on this bracket

enter image description here

0 个答案:

没有答案