ios - Can't call method from UIView extension -


i'm trying call method extending 1 of custom uiviews, error "value of type 'mycustomview' has no member 'testmethod'". below code

extension mycustomview {   func testmethod() {     //do stuff here   } }  //in separate class extension  class func onmoreoptionsbuttonpressed(currentviewcontroller:uiviewcontroller) {   view in currentviewcontroller.view.subviews {     if view.iskindofclass(mycustomview) {       let mycustomview = view as! mycustomview       mycustomview.testmethod()     }   } } 

obviously implement functionality bunch of different ways, i'm more interested in why code won't compile, because seems logically correct me. appreciated.

this may have fact uiview objective-c class , method dispatching differs pure swift classes.

you may have declare extension's method dynamic directive satisfy method dispatch mechanism of obj-c.

(i haven't tried mind you)


Comments