fileSystemRepresentationWithPath:
指定したパスの内容を表すC文字列を返します
-(const char *)fileSystemRepresentationWithPath:(NSString *)path:
解説
指定したパスの内容を表すC文字列を返します。
返り値
( const char * )
C文字列
引数
( NSString * )path
パス
フレームワーク
Foundation
クラス
NSFileManager
Instance Methods
使用可能
10.0
参照
- stringWithFileSystemRepresentation:length:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { //OSType *ost; NSFileManager *myFile = [ NSFileManager defaultManager]; const char *cStr; //開けるファイル拡張子の配列 NSArray *imgTypes = [ NSArray arrayWithObject : @"tiff" ]; //OpenPanelを作る NSOpenPanel *opImage = [ NSOpenPanel openPanel ]; //OpenPanelの結果のボタン番号 int opRet; //OpenPanelでファイル選択 opRet = [ opImage runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Pictures" //どのファイルを選択しておくか types : imgTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら cStr = [myFile fileSystemRepresentationWithPath:[[ opImage filename ] stringByExpandingTildeInPath]]; NSLog([NSString stringWithCString:cStr]); } } @end