title: In iOS tweak development, I cannot overwrite/write file with :writeToFile:atomically method
body: <p>First of all, I am new to iOS tweak development and sorry if I asked something really seems like dumb. However, I cannot figure out what is the actual problem yet.</p>
  <h2>In the following code, I want to do:</h2>
  <ul>
  <li>Edit the 'integer' value in the dictionary.</li>
  </ul>
  <h2>So what I did (Expected):</h2>
  <ol>
  <li><p>Read the application's 'plist' file in the data container. (/var/mobile/Containers/Data/Application//Library/Preferences/...plist)</p>
  </li>
  <li><p>Edit the specific integer value from plist by resetting(removing and setting the value again) because the value is immutable.</p>
  </li>
  <li><p>Save to the file with the <code>writeToFile</code> method.</p>
  </li>
  </ol>
  <h2>Environment:</h2>
  <ul>
  <li>THEOS with WSL1.0 (Windows Pro 1909)</li>
  <li>iPhone 10,4 with iOS 13.5 (Unc0ver)</li>
  </ul>
  <p>Also, the following code is in the preference bundle template.</p>
  <h2>CODE:</h2>
  <pre class="lang-c prettyprint-override"><code>        // NOTE: Show alert&lt;loading&gt;(applying);
          UIAlertController *alertLoading = [UIAlertController
              alertControllerWithTitle:@&quot;Applying settings&quot;
              message:@&quot;The settings are being applied...&quot;
              preferredStyle:UIAlertControllerStyleAlert
          ];
          [self presentViewController:alertLoading animated:YES completion:nil];
  
          // NOTE: Get application UUID and data container path.
          FBApplicationInfo *applicationProxy = [LSApplicationProxy applicationProxyForIdentifier:applicationBundleIdentifier];
          NSString *applicationDataContainerPath = applicationProxy.dataContainerURL.path;
          NSString *applicationPreferencePath = [NSString stringWithFormat:@&quot;%@/Library/Preference/%@.plist&quot;, applicationDataContainerPath, tweakBundleIdentifier];
  
          // NOTE: Read preference file into memory and find the object.
          NSMutableDictionary *applicationPreference = [[NSMutableDictionary alloc] initWithContentsOfFile:applicationPreferencePath];
          NSMutableDictionary *applicationPreferenceAdUnitSetting = [applicationPreference[@&quot;AdFitStore&quot;][@&quot;AdUnitSetting&quot;] objectAtIndex:0];
  
          int KakaotalkAdfitUnitPreferenceMaxReqCount = 0;
  
          // NOTE: Check if the extension is enabled;
          if ([isEnabled isEqual:@0]) {
              // NOTE: Disabled;
              KakaotalkAdfitUnitPreferenceMaxReqCount = 20;
          }
  
          // NOTE: Update the value.
          [applicationPreferenceAdUnitSetting removeObjectForKey:@&quot;fcMaxCount&quot;];
          [applicationPreferenceAdUnitSetting setObject:[NSNumber numberWithInt:KakaotalkAdfitUnitPreferenceMaxReqCount] forKey:@&quot;fcMaxCount&quot;];
  
          // NOTE: Write preference file into original path.
          [applicationPreference writeToFile:@applicationPreferencePath atomically:YES];
  
          // NOTE: Hide alert&lt;loading&gt;(applied);
          [self dismissViewControllerAnimated:YES completion:nil];
  </code></pre>
  <h2>Original PLIST file:</h2>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
  &lt;plist version=&quot;1.0&quot;&gt;
  &lt;dict&gt;
      &lt;key&gt;AdFitStore&lt;/key&gt;
      &lt;dict&gt;
          &lt;key&gt;userAgent&lt;/key&gt;
          &lt;string&gt;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148&lt;/string&gt;
          &lt;key&gt;AdFitSDKVersion&lt;/key&gt;
          &lt;string&gt;3.3.4&lt;/string&gt;
          &lt;key&gt;AdFitSAL&lt;/key&gt;
          &lt;dict&gt;
              ...
          &lt;/dict&gt;
          &lt;key&gt;AdUnitSetting&lt;/key&gt;
          &lt;dict&gt;
              &lt;key&gt;DAN-1hux82hxke720&lt;/key&gt;
              &lt;dict&gt;
                  &lt;key&gt;reqInterval&lt;/key&gt;
                  &lt;integer&gt;0&lt;/integer&gt;
                  &lt;key&gt;fcMaxCount&lt;/key&gt;
                  &lt;integer&gt;0&lt;/integer&gt;
                  &lt;key&gt;lastViewabledDate&lt;/key&gt;
                  &lt;date&gt;2020-07-09T12:25:30Z&lt;/date&gt;
                  &lt;key&gt;nextResetDate&lt;/key&gt;
                  &lt;date&gt;2020-07-09T15:00:00Z&lt;/date&gt;
                  &lt;key&gt;lastRequestedDate&lt;/key&gt;
                  &lt;date&gt;2020-07-11T17:14:51Z&lt;/date&gt;
                  &lt;key&gt;fcInterval&lt;/key&gt;
                  &lt;integer&gt;0&lt;/integer&gt;
                  &lt;key&gt;viewableCount&lt;/key&gt;
                  &lt;integer&gt;1&lt;/integer&gt;
              &lt;/dict&gt;
          &lt;/dict&gt;
      &lt;/dict&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>