macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

fileOwnerAccountID

ファイルオーナーアカウントIDを返します

解説

ファイルオーナーアカウントIDを返します。NSFileOwnerAccountIDキーがなければいけません。

返り値

( NSNumber * )

作った辞書

引数

クラス

NSDictionary

Instance Methods

使用可能

10.2
iOS2.0

参照

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSString *str = @"~/";
NSFileManager *myFile = [ NSFileManager defaultManager];
//ファイル属性
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
            [NSDate date],NSFileModificationDate,
            @"owner",@"NSFileOwnerAccountName",
            @"group",@"NSFileGroupOwnerAccountName",
			[NSDate date],@"NSFileCreationDate",
			[NSNumber numberWithBool:YES],@"NSFileAppendOnly",
			[NSNumber numberWithBool:YES],@"NSFileImmutable",
			[NSNumber numberWithUnsignedInt:12],@"NSFileOwnerAccountID",
            nil,@"NSFilePosixPermissions",
            [NSNumber numberWithBool:YES],@"NSFileExtensionHidden",
            nil];
//書き込むデータ
NSString *str2 = @"Mutable data";
NSData *dat = [[[NSData alloc] init] autorelease];

NSMutableData *dat1 = [[[NSMutableData alloc] autorelease] initWithCapacity:1];
[dat1 appendBytes:[str2 cString] length:[str2 cStringLength]];

[myFile changeCurrentDirectoryPath:[str stringByExpandingTildeInPath]];
[myFile createFileAtPath:@"createdNewFile" contents:dat1 attributes:dic];
dat = [myFile contentsAtPath:@"createdNewFile"];

NSLog(@"fileCreationDate %@",[[dic fileCreationDate] description]);
NSLog(@"fileModificationDate %@",[[dic fileModificationDate] description]);
([dic fileIsAppendOnly]) ? NSLog(@"YES") : NSLog(@"NO") ;
([dic fileIsImmutable]) ? NSLog(@"fileIsImmutable YES") : NSLog(@"fileIsImmutable NO") ;
NSLog([[dic fileOwnerAccountID] description]);
NSLog([[dic fileOwnerAccountID] description]);
}

@end