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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -