title: Objective C set ownership to file
body: <p>I want to change files permissions and files ownership(root o mobile)
  I already found out how to set permissions(777) successfully.
  But now I am trying to get the files ownership.</p>
  
  <p>Here is what I already got, but it does not seem to work:</p>
  
  <pre><code>NSMutableDictionary *dict2 = [[NSMutableDictionary alloc] init]; 
      [dict2 setObject:[NSString stringWithFormat:@"mobile"] forKey:NSFileOwnerAccountName]; 
      [dict2 setObject:[NSString stringWithFormat:@"mobile"] forKey:NSFileGroupOwnerAccountName];
      NSFileManager *fm2 = [NSFileManager defaultManager]; 
      NSError *error2; 
      [fm2 setAttributes:dict2 ofItemAtPath:omgPath error:&amp;error2];
  </code></pre>
  
  <p>Can someone help me with this? :)</p>
  
  <p>Here is the working code for permissions:</p>
  
  <pre><code>NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; 
      [dict setObject:[NSNumber numberWithInt:511] forKey:NSFilePosixPermissions]; 
      NSFileManager *fm = [NSFileManager defaultManager]; 
      NSError *error1; 
      [fm setAttributes:dict ofItemAtPath:omgPath error:&amp;error1];
  </code></pre>
  
  <p>Here is another big Problem:</p>
  
  <p>Without file permissions(if the file does not have permissions) I can't use the chown command otherwise I would use this.
  If the ownership for the "owner" is root, I can't run the permissions script. so I have to get one working without the requirement to the other.</p>
  
  <p>so setting ownership does not work without permissions
  setting permissions only work if ownership is mobile, not root</p>
  
  <p>Any ideas?</p>