title: iOS check if a file is being written
body: <p>I have this code that saves a JSON file:</p>
  
  <pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
      tabController = [self.storyboard instantiateViewControllerWithIdentifier:@"cCustomTabController"];
      dValue = [dConfiguration objectForKey:@"Buttons"];
      int i = 0;
  
      for (NSString* sProperty in dValue) {
          NetworkStatus internetStatus = [_reachabilityInfo currentReachabilityStatus];
          NSData *itemData = Nil;
          if (internetStatus != NotReachable)
              itemData = [util getSpecificJsonData:[sProperty valueForKeyPath:@"Item"]];
          if(itemData != nil){
              [util saveJSON:itemData withName:[NSString stringWithFormat:@"%@%@",[sProperty valueForKeyPath:@"Item"],[CommonsUtils getCommonUtil].getAppLanguage]];
              i++;
          }
      }
  });
  </code></pre>
  
  <p>Let's say that I use this JSON to configure my next screen, so in my bundle I already have a JSON file to avoid the file does not exist but I always update it from the server to have the last configuration possible.</p>
  
  <p>My problem is the sometimes it takes a while to save or download the file and my next screen goes black because it does not get the file property, so is my guess that the file at that moment is being written.</p>
  
  <p>So my question is if there is a way to know if the file is being written or there is a workaround to confirm that the file is some how accesible to then read it.</p>
  
  <p>This is an example of what I do when I read the file:</p>
  
  <pre><code>if (_JsonData == nil) {
      NSString *jsonPath = [NSString stringWithFormat:@"%@/%@.json",[NSSearchPathForDirectoriesInDomains (NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0],_JsonConfigFile];
      _JsonData = [NSData dataWithContentsOfFile:jsonPath];
  }
  if (_JsonData != nil) {
      dConfiguration =[NSJSONSerialization JSONObjectWithData:_JsonData options:kNilOptions error:nil];
  }
  </code></pre>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>I need to use a queue to speed up things, so is necessary to my app, in fact I'm changing the code to this because the app takes too much time to get this files, it depends on the client but now one of them is pulling 7 files of configuration and the performance is bean affected.</p>