【问题标题】:Instance member 'index' cannot be used on type 'RouteAction' [duplicate]实例成员“索引”不能用于类型“RouteAction”[重复]
【发布时间】:2016-12-21 12:27:58
【问题描述】:

我在类中声明了属性:

class RouteAction {

    var index: Int = 0

我尝试在我的方法中使用(打印)index

class func workingWithIndex() {

  print(index)
}

但看到错误

实例成员“索引”不能用于类型“RouteAction”

为什么以及如何在我的方法中使用index

【问题讨论】:

    标签: ios swift


    【解决方案1】:

    Index 是一个实例变量,所以它必须是这样的:

    class func workingWithIndex()
    {
        let action = RouteAction()
        print (action.index)
    }
    

    【讨论】:

      猜你喜欢
      • 2015-11-27
      • 2016-05-23
      • 2016-01-01
      • 2016-09-09
      • 2020-01-16
      • 2017-06-25
      • 2016-07-05
      • 2017-01-25
      相关资源
      最近更新 更多