title: NSFileManager creating folders herarichy & not saving plist [open]
body: <p>The problem is appearing on device not on simulator.</p>
  
  <pre><code> NSError *error;
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Plist1.plist"]; 
  
      NSFileManager *fileManager = [NSFileManager defaultManager];
  
      NSLog(@"documentsDirectory  --- %@", documentsDirectory);
      NSLog(@"path --- %@", path);
      @try
      {
          if (![fileManager fileExistsAtPath:path])
          {
              [fileManager copyItemAtPath:documentsDirectory toPath:path error:&amp;error];
          }
      }
      @catch (NSException *exception)
      {
          NSLog(@" [exception description] -- %@", [exception description]);
      }
      @finally {
  
      }
  
      [dictEmot writeToFile:path atomically:YES];
  
      // To verify
      NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
      NSLog(@"[dict allKeys] My plist ----- %@", [dict allKeys]); 
  </code></pre>
  
  <p>Above is the code which I have written to save two plist files in my documents directory. same method I use to save my second plist. </p>
  
  <pre><code>[self savePlist:plist1];
  [self savePlist:plist2];
  </code></pre>
  
  <p>My problem is whenever I try to save second plist it creates hierarchy of folders inside documents directory and also not saves my plist2 file with it contents.</p>
  
  <p>once it complets the 2nd method call, my app documents directory looks like below,</p>
  
  <pre><code>Documents
   -&gt; plist1
     -&gt; plist1
        .
        .
        .
       -&gt; plist1
         -&gt; plist1
  other files
  </code></pre>
  
  <p>I treid doing on main thread also but same result.</p>
  
  <p>its not even printing exception.</p>
  
  <ul>
  <li>What is my mistake ? 
  <h2>- Why its creating hierarchy ?</h2></li>
  </ul>