Reputation: 11098
Here is the objective-c code:
options.onPan = ^(MDCPanState *state){
if (state.thresholdRatio == 1.f && state.direction == MDCSwipeDirectionLeft) {
NSLog(@"Let go now to delete the photo!");
}
};
Swift:
var options = MDCSwipeToChooseViewOptions()
options.delegate = self
options.likedText = "Keep"
options.likedColor = UIColor.blueColor()
options.nopeText = "Delete"
options.onPan = { (state: MDCPanState) in
if state.thresholdRatio == 1.0 && state.direction == MDCSwipeDirection.Left {
println("Let go now to delete the photo!");
}
}
This is throwing an error:
'(MDCPanState) -> (MDCPanState) -> $T2' is not convertible to 'MDCPanState'
Would appreciate some help thanks.
Upvotes: 0
Views: 84
Reputation: 1421
I'm not 100% since I don't have XCode near me at the moment, but I believe you need to change this:
options.onPan = { (state: MDCPanState) in
if state.thresholdRatio == 1.0 && state.direction == MDCSwipeDirection.Left {
println("Let go now to delete the photo!");
}
to this:
options.onPan = { (state: MDCPanState!) -> Void in
if state.thresholdRatio == 1.0 && state.direction == MDCSwipeDirection.Left {
println("Let go now to delete the photo!");
}
Upvotes: 1