| Home 目次>Foundation>NSFileManager このサイトはこちらに移転しました。 | |
stringWithFileSystemRepresentation:length:
指定したC文字列と範囲で、ファイルシステムでの文字列を返します
-(NSString *) stringWithFileSystemRepresentation:(const char *)str
length:(unsigned)len
【返り値】 | |
| NSString * | 文字列 |
| 【パラメータ】 | |
| str | C文字列 |
| len | 範囲 |
【解説】
指定した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([myFile stringWithFileSystemRepresentation:cStr length: 10 ]);
}
}
@end
![]() | |
この記事を評価してください。
| Home 目次>Foundation>NSFileManager | 修正日2006.12.26 |