我刚开始用Objective-C在很长一段时间后快速学习。按照苹果公司的建议,我选择了操场进行编码和学习。代码如下:

class Polygon
{
    var color:UIColor = UIColor.clearColor()

    var numberOfSides:Int = 0 {
        willSet(newNumber)
        {
            println("willSet is being called")
        }
        didSet(newNumber)
        {
            println("didSet is being called")

            //just to make sure didSet is called
            numberOfSides = 12345678
        }
    }
}

var polygon1 = Polygon()

polygon1.numberOfSides = 222222
polygon1.numberOfSides = 1

var polygon2 = Polygon()
polygon2.numberOfSides = 12313

它和2+2一样简单,多边形的行为也和预期的一样。问题是:println()调用的结果在哪里(请参见嵌入的图像)?事先谢谢。

最佳答案

print/println函数的输出转到控制台-您可以在助手编辑器中看到它(使用app menu view->assistant editor->show assistant editor显示它,或使用键盘alt+cmd+entershortcut)

10-08 15:42