HungCLo HungCLo - 2 years ago 62
Swift Question

Instance member can not be used in swift

The project is to create a JSON object.

code is 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 //< The following error shows on this line

This line always appears Error

Answer Source

appID is a instance variable but getJSONObject is a class method. So it will not work. You have to redesign it somehow.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download