NSFileManager:createDirectoryAtPath:attributes:
Home 目次>Foundation>NSFileManager

createDirectoryAtPath:attributes:

属性を指定して空のディレクトリ(フォルダ)を作ります


-(BOOL) createDirectoryAtPath:(NSString *)path
   attributes:(NSDictionary *)attributes


【返り値】
   BOOLYES/NO
【パラメータ】
   pathパス
   attributes属性の辞書


【解説】

属性を指定して空のディレクトリ(フォルダ)を作ります。
作ることができればYESを返します。
できなければNOを返します。
同じ名前のディレクトリ(フォルダ)がある場合は作られない。
親ディレクトリ(フォルダ)がない場合は作られない。
【attributes】ディレクトリ(フォルダ)の属性
キー 値タイプ
●NSFileOwnerAccountName 所有者名(NSString)
●NSFileGroupOwnerAccountName グループ名(NSString)
● NSFileModificationDate ファイル修正日(NSDate)
● NSFilePosixPermissions POSIXのファイル属性(読み込み・書き込みなど)(NSNumber)
● NSFileExtensionHidden 拡張子を隠すか(BOOLのNSNumber)
● NSFileHFSCreatorCode クリエータタイプ(unsigned longのNSNumber)
● NSFileHFSTypeCode ファイルタイプ(unsigned longのNSNumber)



【例文】


#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",
nil,@"NSFilePosixPermissions",
[NSNumber numberWithBool:YES],@"NSFileExtensionHidden",
nil];

[myFile changeCurrentDirectoryPath:[str stringByExpandingTildeInPath]];
[myFile createDirectoryAtPath:@"newFolder" attributes:dic];

NSLog([myFile currentDirectoryPath]);
}

@end


(C) 2000-2007 Satoshi Oomori.
[Apple]

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

この記事を評価してください。 

良い 

間違いがある 説明がわかりにくい 例文がわかりにくい  

Home 目次>Foundation>NSFileManager
修正日2006.12.26