title: Trouble setting long value in singleton IOS
body: <p>I'm having trouble with setting and accessing long properties on a Singleton object. Every time I try to access a long property it returns -1.</p>
  
  <p>My singleton interface file is as follows:</p>
  
  <pre><code> @interface gameData : NSObject &lt;NSCoding&gt;
      @property (assign, nonatomic) long score;
      @property (assign, nonatomic) long level;
      @property (assign, nonatomic) long riddlesCompleted;
      @property (assign, nonatomic) long hints;
      @property (assign, nonatomic) long firstLetters;
      @property (assign, nonatomic) long answers;
  
      +(instancetype)sharedGameData;
      -(void)reset;
      -(void)save;
  
    @end
  </code></pre>
  
  <p>Then the implementation file sets up the encoders and decoders as follows:</p>
  
  <pre><code>-(void)encodeWithCoder:(NSCoder *)aCoder{
      [aCoder encodeDouble:self.score forKey:gameDataScoreKey];
      [aCoder encodeDouble:self.level forKey:gameDataLevelKey];
      [aCoder encodeDouble:self.riddlesCompleted forKey:gameDataRiddlesCompletedKey];
      [aCoder encodeDouble:self.hints forKey:gameDataHintsKey];
      [aCoder encodeDouble:self.firstLetters forKey:gameDataFirstLettersKey];
      [aCoder encodeDouble:self.answers forKey:gameDataAnswersKey];
  }
  -(instancetype)initWithCoder:(NSCoder *)decoder{
      self = [self init];
      if (self) {
          _score = [decoder decodeDoubleForKey:gameDataScoreKey];
          _level = [decoder decodeDoubleForKey:gameDataLevelKey];
          _riddlesCompleted = [decoder decodeDoubleForKey:gameDataRiddlesCompletedKey];
          _hints = [decoder decodeDoubleForKey:gameDataHintsKey];
          _firstLetters = [decoder decodeDoubleForKey:gameDataFirstLettersKey];
          _answers = [decoder decodeDoubleForKey:gameDataAnswersKey];
      }
      return self;
  }
  
  +(instancetype) sharedGameData{
      static id sharedInstance = nil;
  
      static dispatch_once_t onceToken;
      dispatch_once(&amp;onceToken, ^{
          sharedInstance = [self loadInstance];
      });
      return sharedInstance;
  }
  </code></pre>
  
  <p>Values are initialised as follows:</p>
  
  <pre><code>-(id)init{
      if(self = [super init]){
          _score = 500;
          _riddlesCompleted = 0;
          _level = 1;
          _hints = 3;
          _firstLetters = 3;
          _answers = 3;
      }
      return self;
  }
  </code></pre>
  
  <p>and then the instance is loaded: </p>
  
  <pre><code>+(NSString*)filePath{
      static NSString* filePath = nil;
      if (!filePath) {
          filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) firstObject]
                      stringByAppendingString:@"gameData"];
      }
      return filePath;
  }
  
  +(instancetype)loadInstance{
      NSData* decodeData = [NSData dataWithContentsOfFile:[gameData filePath]];
      if (decodeData) {
          gameData* gameData = [NSKeyedUnarchiver unarchiveObjectWithData:decodeData];
          return gameData;
      }
      return [[gameData alloc] init];
  }
  </code></pre>
  
  <p>Then elsewhere in the application when I try to access these values I am not able to access the values of hints, firstletters or answers.  </p>
  
  <p>If I try logging the values as follows: </p>
  
  <pre><code>NSLog([NSString stringWithFormat:@"%li", [gameData sharedGameData].score] );
  NSLog([NSString stringWithFormat:@"%li", [gameData sharedGameData].hint] );
  NSLog([NSString stringWithFormat:@"%li", [gameData sharedGameData].answers]);
  NSLog([NSString stringWithFormat:@"%li", [gameData sharedGameData].firstLetters]);
  </code></pre>
  
  <p>The output I get is 500 for score but for all the others I get 0 even though they are initialised in the gameData.m file with values 3.  </p>