I'm working on a crosswords app in Swift and I want to show a certain webView only when it matches a certain condition.
Here's my snippet:
if (completedPuzzles.count == 25) {
self.view.addSubview(webView)
let myURL = URL(string:"https://he8eymyf1s6.typeform.com/to/iEKxw8gl")
let myRequest = URLRequest(url: myURL!)
backButton()
webView.load(myRequest)
}
Now I show the webView when the number of completed puzzles counts as 25 but it seems that for the people who already completed 25 before this update, they are ignored.
How can I make sure that people see the webView even if they already completed 25 before the update and not ignore it?
CodePudding user response:
if i understand it correctly you want to do it every time a user played 25 games if that is true you can do something like this
var var numberOfWebpagesShown = 0
if (completedPuzzles.count % 25 == 0 || numberOfWebpagesShown < completedPuzzles.count / 25 ) {
self.view.addSubview(webView)
let myURL = URL(string:"https://he8eymyf1s6.typeform.com/to/iEKxw8gl")
let myRequest = URLRequest(url: myURL!)
backButton()
webView.load(myRequest)
}
this will show the webview everytime the completedPuzzles.count is dividable by 25 like 25, 50, 75 and so on. and do it if a user havent been shown a webpage for their current stage