| Home 目次>Foundation>NSFileManager このサイトはこちらに移転しました。 | |
fileSystemRepresentationWithPath:
指定したパスの内容を表すC文字列を返します
-(const char *) fileSystemRepresentationWithPath:(NSString *)path
【返り値】 | |
| const char * | C文字列 |
| 【パラメータ】 | |
| path | パス |
【解説】
指定したパスの内容を表すC文字列を返します。
【例文】
#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
![]() | |
この記事を評価してください。
| Home 目次>Foundation>NSFileManager | 修正日2006.12.26 |