Reputation: 2890
I'm trying to use a third-party library written in objective-c in my project written with Swift. I have copied the file into the project and built the bridge file, and is able to reference the class in the library and use the properties. But I'm not able to call the instance function in the library, XCode just complaining value of type 'EFCircularSlider' has no member 'setInnerMarkingLabels'
. The code is below:
function in the lib:
-(void)setInnerMarkingLabels:(NSArray*)innerMarkingLabels
{
_innerMarkingLabels = innerMarkingLabels;
[self setNeedsUpdateConstraints]; // This could affect intrinsic content size
[self setNeedsDisplay]; // Need to redraw with new label texts
}
the way to call in swift:
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let hourSliderFrame = CGRectMake(55, 220, 210, 210)
hourSlider = EFCircularSlider(frame: hourSliderFrame)
hourSlider.unfilledColor = UIColor(red: 23/255.0, green: 47/255, blue: 70/255, alpha: 1.0)
let markingLabels = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]
hourSlider.setInnerMarkingLabels(markingLabels)
}
Upvotes: 1
Views: 194
Reputation: 285069
You probably have to use the property (dot) assignment notation rather than calling the explicit setter
hourSlider.innerMarkingLabels = markingLabels
PS: where is hourSlider
initialized? The code as-is will not compile.
The documentation says
You access properties on Objective-C objects in Swift using dot syntax, using the name of the property without parentheses.
Upvotes: 1