Binh Binh - 1 year ago 85
Swift Question

Error accessing function of class while converting Obj C project to Swift

I added my swift class to the target while removing my header file of the same objective C class from the target but this error shows when I try and build my project. I can't attach an image right now but the error states: "Use of instance member 'url' on type 'ServerURLFactory'; did you mean to use a value of type 'ServerURLFactory' instead?"

let accessURL: NSURL = NSURL(string: "\(ServerURLFactory.url())/CygnetInstanceXMLServlet?cygnetId=\(idNumber)")!


Has anyone ran into a similar problem and how to fix this confusing bug? Its as if the program is still trying to call the Obj C function instead of explicitly calling the one in the Swift file.

Answer Source

You're calling .url() on ServerURLFactory itself as a type:


I guess you should instantiate the class first. Probably something like this, but it depends on how the class is implemented:

let factory = ServerURLFactory()


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