-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compile failed with method conflict error #595
Comments
You are getting this because there is a ViewController method in a UIView category in my library. You could try changing your variable name. |
I checked this and found that if UIView has other category class having same method name then library code compiles fine and works fine. This is the only issue with subclasses. So I decided to keep |
@hackiftekhar , I am experiencing a similar issue. My project is using both The name conflict is caused by two third-parties, so changing a property name is not an option for me. /**
* Inside ScanditBarcodeScanner.framework
*/
@interface SBSBarcodePickerView : UIView
{
// ...
@property (nonnull, nonatomic, strong, readonly) SBSBarcodePicker *viewController;
} P.S. Could you please re-consider using some sort of prefixes for your UIKit extensions? |
Detaching the introspection logic from UIView could be a good option too. class UIViewUtils
{
public static func viewController(for view: UIView)->UIViewController?
{
var nextResponder: UIResponder? = view
repeat {
nextResponder = nextResponder?.next
if let viewController = nextResponder as? UIViewController {
return viewController
}
} while nextResponder != nil
return nil
}
// rest of IQUIView+Hierarchy methods rewritten in the same manner
} |
So my workaround is making another category... In Objective-C... #import <ScanditBarcodeScanner/ScanditBarcodeScanner.h>
@interface SBSBarcodePickerView (ViewControllerGetter)
@property (nonnull, nonatomic, strong, readonly) SBSBarcodePicker* scanVC;
@end #import "SBSBarcodePickerView+ViewControllerGetter.h"
@implementation SBSBarcodePickerView (ViewControllerGetter)
@dynamic scanVC;
-(SBSBarcodePicker*)scanVC
{
return self.viewController;
}
@end |
hmm, thanks for letting me know, I'll try to change it's name with some prefix. |
It's now fixed |
when i has code below in my project
I got an compile error
Getter for 'viewController' with Objective-C selector 'viewController' conflicts with method 'viewController()' from superclass 'UIView' with the same Objective-C selector
,is there any way to fix this problem without changing my code ?The text was updated successfully, but these errors were encountered: