I'm trying to call a method by extending one of my custom UIViews, but I get the error "Value of type 'MyCustomView' has no member 'testMethod'". Below is my code
extension MyCustomView {
func testMethod() {
//do stuff here
}
}
//in a separate class from the extension
class func onMoreOptionsButtonPressed(currentViewController:UIViewController) {
for view in currentViewController.view.subviews {
if view.isKindOfClass(MyCustomView) {
let myCustomView = view as! MyCustomView
myCustomView.testMethod()
}
}
}
Obviously I could implement this functionality a bunch of different ways, but I'm more interested in why specifically this code won't compile, because it seems logically correct to me. All help is greatly appreciated.