简体   繁体   中英

I can't override a method of a class imported from cocoapods in swift

I've installed a pod from cocoapods named SwiftHSVColorPicker. It's working fine. But when I try to subclass one class of this pod (which is a public class), it's given an error when trying to override the method hueAndSaturationSelected(hue:saturation:) saying that the method doesnt exist in the class.Below it's a print of my subclass: 在此输入图像描述 Below it's a print of the referred method: 在此输入图像描述

If a try to create the class inside the same folder of the class SwiftHSVColorPicker, it says that swift is not supported for static libraries. (Besides the fact I even dont know if this class would remain there in case of a new pod install ). How to override this method?

I had a similar issue and I solved it by only importing the file I was overriding. So in your case, instead of having #import SwiftHSVColorPicker/SwiftHSVColorPicker.h in the header of your sublcass, you would add #import SwiftHSVColorPicker/ClassYouAreOverriding.h

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM