Thursday, May 9, 2013

NSDictionary NSFileGroupOwnerAccountName example ios


fileGroupOwnerAccountName - NSFileGroupOwnerAccountName

Returns the value for the NSFileGroupOwnerAccountName key.
- (NSString *)fileGroupOwnerAccountName
Return Value
The value for the key NSFileGroupOwnerAccountName, or nil if the dictionary doesn’t have an entry for the key.
Discussion of [NSDictionary NSFileGroupOwnerAccountName]
This and the other file... methods are for use with a dictionary, such as those returned from the methodsfileAttributesAtPath:traverseLink: (NSFileManager), directoryAttributes(NSDirectoryEnumerator), and fileAttributes (NSDirectoryEnumerator), that represents the POSIX attributes of a file or directory. This method returns the name of the corresponding file’s group.
Example of [NSDictionary NSFileGroupOwnerAccountName]
NSFileManager *fileManager = [NSFileManager defaultManager];
NSMutableDictionary *attr = [NSMutableDictionary dictionary]; 
[attr setObject:@"root" forKey:NSFileOwnerAccountName];
[attr setObject:@"wheel" forKey:NSFileGroupOwnerAccountName]; 
[attr setObject:[NSNumber numberWithInt:0755] forKey:NSFilePosixPermissions];

[fileManager createDirectoryAtPath:dir withIntermediateDirectories:TRUE attributes:attr error:&error];
Example of [NSDictionary NSFileGroupOwnerAccountName]
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
                          @"mobile",NSFileOwnerAccountName,
                          @"mobile",NSFileGroupOwnerAccountName,
                          nil];

NSError *error = nil;
[[NSFileManager defaultManager] setAttributes:dict ofItemAtPath:omgPath error:&error];
if(error){
    NSLog(@"Error settings permission %@",[error description]);
}
Example of [NSDictionary NSFileGroupOwnerAccountName]
NSFileManager *fm = [NSFileManager defaultManager];
NSError *error = nil;
NSDictionary *attr = [fm attributesOfItemAtPath:@"/" error:&error];
if (!error) {
    NSLog(@"Attr: %@", attr);
}

2009-10-28 17:21:11.936 MyApp[33149:a0b] Attr: {
    NSFileCreationDate = "2009-08-28 15:37:03 -0400";
    NSFileExtensionHidden = 0;
    NSFileGroupOwnerAccountID = 80;
    NSFileGroupOwnerAccountName = admin;
    NSFileModificationDate = "2009-10-28 15:22:15 -0400";
    NSFileOwnerAccountID = 0;
    NSFileOwnerAccountName = root;
    NSFilePosixPermissions = 1021;
    NSFileReferenceCount = 40;
    NSFileSize = 1428;
    NSFileSystemFileNumber = 2;
    NSFileSystemNumber = 234881026;
    NSFileType = NSFileTypeDirectory;
}