zoukankan      html  css  js  c++  java
  • 关于ios8斯坦福公开课第二课

    在这个课程中,我们遇到了这样的代码

        @IBAction func oprate(sender: UIButton) {
            let opration = sender.currentTitle!
            if userIsOnInput {
                enter()
            }
            switch opration {
            case "+": performOperation{ $0+$1 }
                
            case "−": performOperation{ $1-$0 }
            case "×": performOperation{ $0*$1 }
            case "÷": performOperation{ $1/$0 }
    //        case "√": performOperation{ sqrt($0) }
            default: break
            }
            
            
        }
        func performOperation(opretion:(Double,Double) -> Double) {
            if operandStack.count >= 2 {
                displayValue = opretion(operandStack.removeLast(), operandStack.removeLast())
                enter()
            }
        }
        
        /** 并不能闭包参数的重载  */
    //    func performOperation(opretion: Double -> Double) {
    //        if operandStack.count >= 1 {
    //            displayValue = opretion(operandStack.removeLast())
    //            enter()
    //        }
    //    }
    

    视频里运行的各种欢脱,但是我们就是编译不过去。。。  

    注释处错误:在stack Overflow中找到了答案:因为swift语言支持重载,但是OC语言不支持重载!

    话说,我这里哪里和OC有关?这里明明是swift。。。仔细看看,发现UIViewController是继承自NSObject的。。。

    可能是Paul Hegarty使用的XCode版本比较低,所以并没有遇到

  • 相关阅读:
    centos mongo数据库搭建
    闪屏页白屏或者显示旧图
    在Sqlserver下巧用行列转换日期的数据统计
    读 《.Net 之美》解析.Net Remoting (应用程序域)-- Part.1
    MVC的自定义动作过滤器(一)
    【算法】快排
    【编程范式】C语言1
    排序
    日志记录类
    邮箱发送类
  • 原文地址:https://www.cnblogs.com/LiuLady12138/p/4952343.html
Copyright © 2011-2022 走看看