Intro
I am creating a Swift 2.0
app in which an action can be performed only a certain number of times, say 8. In order to accomplish this behavior, I need to cancel a certain segue, performAction
, should it be triggered via pressing a button linked to it on storyboard.
Research
I ran across questions like http://stackoverflow.com/questions/8066525/prevent-segue-in-prepareforsegue-method, which suggested code like:
override func shouldPerformSegueWithIdentifier(identifier: String,sender: AnyObject?) -> Bool {
return true
}
Implementation
I implemented it like:
override func shouldPerformSegueWithIdentifier(identifier: "createCard" ,sender: AnyObject?) -> Bool {
if amountOfTimes > 8 { //To be triggered if the segue should be cancelled
return false
} else {
return true
}
}
However I get the error
Expected ',' seperator
How can I have the segue be cancelled should amountOfTimes
be greater than 8?