1

I have a basic class named APIGroup that exists for the sole purpose of subclassing (it is not [yet] used for anything but certain static properties that are accessed by the subclasses). It looks somewhat like this:

public class APIGroup {
    public static let someProperty : String = "I am a property!"
}

And I have a subclass, Track, which defines a type method search as follows:

public class Track : APIGroup {
    public static func search(name: String) -> Void {
        print("Track search initiated. Name: \(name)")
        print("And the property is: \(someProperty)")
    }
}

These two classes are defined in separate files in the same module. In another target, I import the module and try to call:

import MyModule

MyModule.Track.search("testing...")

But this throws: Type 'Track' has no member 'search'. What am I doing wrong?

Coder-256
  • 5,212
  • 2
  • 23
  • 51

1 Answers1

0

Putting this code in a Playground works fine for me:

import Foundation

public class APIGroup {
    public static let someProperty : String = "I am a property!"
}

public class Track : APIGroup {
    public static func search(name: String) -> Void {
        print("Track search initiated. Name: \(name)")
        print("And the property is: \(someProperty)")
    }
}

Track.search("testing...")

If they are in the same module you do not need to import or use the module name.

enter image description here

Scriptable
  • 19,402
  • 5
  • 56
  • 72
  • It works for me, too, but see what I said about the different files/modules. – Coder-256 May 21 '16 at 00:58
  • Actually, it just randomly started working. I didn't even change everything, I just tried recompiling a few hours later. Thanks for the help, though! – Coder-256 May 21 '16 at 01:00