ios - Instance member can not be used in swift -


the project create json object.

code below :

public class registerin {      private var appid : string = ""                                   private static let jk_appid : string = "appid"      init(appid: string) {         self.appid = appid     }      class getjsonobject : registerin {         let jsonobject : [string : anyobject] =             [                  jk_appid : appid   //< following error shows on line             ]     } } 

this line appears error

1

you declare "getjsonobject" class (not method) derived registerin class inside super class. why?

2

let jsonobject : [string : anyobject] =         [              registerin.jk_appid : appid            ] 

you can use const values here not instance memeber (of derived class)

3

this code works in playground:

import uikit  public class registerin {      var appid : string = ""      private static let jk_appid : string = "appid"      init(appid: string) {         self.appid = appid     }  }  class getjsonobject : registerin {     let jsonobject : [string : anyobject]     override init(appid: string) {         jsonobject =             [                 registerin.jk_appid : appid         ]         super.init(appid: appid)     } }  let testgetjsonobject = getjsonobject(appid: "test") 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -