title: NSDictionary writetofile is not working
body: <p>I'm trying to save some user settings using NSDictionary writetofile but it is not working.</p>
  
  <p>I have already checked out similar questions but I could not find out what the problem is.</p>
  
  <p>here's my code: </p>
  
  <pre><code>NSDictionary *settings;
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
  NSString *settingsPath = [NSString stringWithFormat:@"%@/UserSettings.plist", [paths objectAtIndex:0]];
  BOOL settingsExist = [[NSFileManager defaultManager] fileExistsAtPath:settingsPath];
  if(settingsExist){
      NSLog(@"file found!");
      settings = [NSDictionary dictionaryWithContentsOfFile:settingsPath];
  }else{
      NSLog(@"file not found!");
      settings = [[NSDictionary alloc] initWithObjectsAndKeys:@"iPhone",@"device", nil];
      [[NSFileManager defaultManager] createFileAtPath:settingsPath contents:nil attributes:nil];
      if([settings writeToFile:settingsPath atomically:YES]){
          NSLog(@"success!");
      }else{
          NSLog(@"fail!");
      }
  }
  </code></pre>
  
  <p>It keeps returning 'fail!'.
  Could you help me with this please?</p>