+ 1

Help with my code

Hi all I’ve Inserted a Brief part of my code below. I have an Issue where when I press start button It sometimes shows winner on the win label when there are no matching wins. Idea Is to match 3,4 or 5 of the Same number In a line. Any help Is greatly appreciated https://code.sololearn.com/ctoHIw6mS0OU/?ref=app

12th Sep 2019, 2:27 PM
Kevin
19 Respostas
+ 1
https://www.bing.com/videos/search?q=how+to+save+score+files+swift&view=detail&mid=B98BEC9CA8401EC54B08B98BEC9CA8401EC54B08&FORM=VIRE&PC=LNCH10 and https://www.bing.com/videos/search?q=how+to+save+score+files+swift&view=detail&mid=F61E465D7B94B8DC3FA9F61E465D7B94B8DC3FA9&FORM=VIRE&PC=LNCH10
25th Sep 2019, 7:18 PM
Felix Schültz
Felix Schültz - avatar
+ 1
You need to add a code that will randomly pick an input itself https://code.sololearn.com/cX0AVQuZ5MnP/?ref=app https://code.sololearn.com/cxDCDg0tB01i/?ref=app
25th Sep 2019, 4:28 PM
Felix Schültz
Felix Schültz - avatar
+ 1
thanks man il defo give this a try another problem iv ran into is that the score doesnt work properly. it adds up fine. when changing VC’s or exiting game it remembers the score however when score = 0 then change vC it sets the score back to the previous score i got. ive used user.defaults.standard any idea how to fix this ? i need it to remember the current score when exiting game and when changing views but when score is zero it needs to rember that when changing VC’s or exiting
25th Sep 2019, 4:45 PM
Kevin
+ 1
Yes, but to do that you need to have a valid way to save these files in order to save thishttps://code.sololearn.com/coy8y33CrBkh/#swift
25th Sep 2019, 5:20 PM
Felix Schültz
Felix Schültz - avatar
+ 1
thank you for taking the time to help me out with this as i am new at coding. do you know of any youtube videos you could reccommend to me to help me understand how to save the score files ?
25th Sep 2019, 5:34 PM
Kevin
+ 1
thank you alot il check this out 👍
25th Sep 2019, 8:07 PM
Kevin
+ 1
i have saved my high score the same way they have done it on these videos and that part works perfectly. the current score is my issue because if i use this technique to save the current score then it acts the same as the high score meaning everytime i start the game or change VC it displays the score as the last score i got to. when lose the score will go back to zero but if i exit app or change VC it displayes the last score i got. could my issue be to do with me passing the score through a segue ? or maybe because i currently have it set up with user.defaults same as the highscore. again i am new so hope im not bugging you too much. its probably an easy fix of which i just currently lack the knowledge of. again thanks for the help
25th Sep 2019, 9:23 PM
Kevin
+ 1
You must use a reset code to do this.
25th Sep 2019, 9:54 PM
Felix Schültz
Felix Schültz - avatar
+ 1
are we talking user.default reset code or something like if score == 0 { score = 0 scoreLabel.text = “0” }. and put this under the code for when changing VC’s ?
25th Sep 2019, 10:01 PM
Kevin
+ 1
Yes
25th Sep 2019, 10:02 PM
Felix Schültz
Felix Schültz - avatar
+ 1
Mabey
25th Sep 2019, 10:02 PM
Felix Schültz
Felix Schültz - avatar
+ 1
hmm interesting... il give that a go tomorrow thanks for the help
25th Sep 2019, 10:04 PM
Kevin
+ 1
Anytime
25th Sep 2019, 10:05 PM
Felix Schültz
Felix Schültz - avatar
+ 1
Has it worked
26th Sep 2019, 2:43 PM
Felix Schültz
Felix Schültz - avatar
+ 1
not just yet. iv added the above if statement to the segue but dont see any difference. in my code i already have a way to set score to 0 when lives is 0 and iv used the same way to record high score to keep the score when changing VC’s but its not working how i need it to. im going to start angela yu ios development course hopefully that will help
26th Sep 2019, 5:11 PM
Kevin
+ 1
Nice
26th Sep 2019, 6:36 PM
Felix Schültz
Felix Schültz - avatar
0
Any luck
30th Sep 2019, 7:53 PM
Felix Schültz
Felix Schültz - avatar
0
not yet iv been going through the course. it is very good and will take a long time to finish theres around 500 videos from beginner to pro but i will coment here again with the answer when i find it out :)
1st Oct 2019, 2:22 PM
Kevin
0
Done yet?
20th Oct 2020, 7:01 PM
Felix Schültz
Felix Schültz - avatar