Keep highscore through app updates with swift

Keep highscore through app updates with swift

By : cold_blade
Date : November 18 2020, 01:01 AM
To fix the issue you can do Yes, NSUserDefaults will stay during App updates.
However, best practice is to save the score via Game Center, iCloud, or any other online storage to avoid lose of data. Facebook is a good choice too.
code :

Share : facebook icon twitter icon
Swift: HighScore / NSUserDefaults

Swift: HighScore / NSUserDefaults

By : user2781438
Date : March 29 2020, 07:55 AM
it should still fix some issue Steve's answer in that related question does not use NSUserDefaults at all, and instead he is archiving & retrieving the high score from a "highScore.archive" file store in your app's Document directory.
Any solution you come up with should forget about user defaults and instead rely on your HighScore object that you instantiate (which loads and saves into that highScore.archive file).
Saving and Loading Up A Highscore Using Swift

Saving and Loading Up A Highscore Using Swift

By : user2968782
Date : March 29 2020, 07:55 AM
I wish this helpful for you I am trying to make a high score view. I load the score and high score up and compare the two to see if the score should be set as the new high score. When the score is a negative number, it works fine, but when the number is positive but less than the current high score or bigger than the high score it seems to add the two numbers together. It also seems to subtract 1 from the two? I'm not really sure whats happening. for the help! , Issue is with this code:
code :
Highscore += Score
Highscore = Score
Swift iOS - Set highscore in gameScene

Swift iOS - Set highscore in gameScene

By : Hayden James Dekker
Date : March 29 2020, 07:55 AM
help you fix your problem I'm making some great progress with my first iOS game app, currently I'm working on the high score element and if anyone would be so kind as to help guide me how to use the correct code. , To me it seems you dont ever call
code :
 if (score > highScore) {
    highScore = score
    highScoreLabelNode.text = NSString(format: "highscore : %i", highScore) as String
How to save highscore swift

How to save highscore swift

By : wwallacemd
Date : March 29 2020, 07:55 AM
will help you I have been trying and searching for something that will help me for a long time but I haven't been able to find a solution yet. I am just trying to save a high score for the game that I am making but it always shows no errors and then gives me weird errors like "Thread 1: signal SIGABRT" when i try and run. Can anyone help me see what I am doing wrong? , Try this code
code :
  import SpriteKit

class GameScene: SKScene {

    var highScoreLabel: SKLabelNode!

    var highestScore:Int = 0

    var score = 0

    override func didMoveToView(view: SKView) {

        highScoreLabel = SKLabelNode(fontNamed: "Chalkduster")
        highScoreLabel.text = "Highscore: \(highestScore)"
        highScoreLabel.horizontalAlignmentMode = .Left
        highScoreLabel.position = CGPoint(x:225, y:100)
        highScoreLabel.zPosition = 2


    override func update(currentTime: NSTimeInterval) {

        var highscore = 1

        let userDefaults = NSUserDefaults.standardUserDefaults()

        highscore = userDefaults.integerForKey("highscore")

        userDefaults.setValue(highscore, forKey: "highscore")

        if score > highscore {
            userDefaults.setValue(score, forKey: "highscore")


        highScoreLabel.text = "highscore: \(highscore)"



My Highscore amount keeps going up and down. Swift SpriteKit

My Highscore amount keeps going up and down. Swift SpriteKit

By : Tillen Okello
Date : March 29 2020, 07:55 AM
To fix this issue The issue is you are reading the highscore from NSUserDefaults and showing it in the HighScoreLabel. But you didn't assigned/stored the value in highscore variable, because of that it remains at 0. That makes the following condition true when you open the app and plays for the first time:
code :
if Score > highscore {
    defaults.setObject("\(Score)", forKey: "Highscore")
if let Highscore1 = defaults.stringForKey("Highscore") {
    HighScoreLabel.text = "HIGHSCORE: \(Highscore1)"

    // Storing current high score to variable
    highscore           = Int(Highscore1)
Related Posts Related Posts :
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • Sidebar menu with indicate navigationbar on iOS
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org