doubleClickAtIndex:
言語特性を考慮に入れて、語の範囲を返します
-(NSRange)doubleClickAtIndex:(unsigned)index:
解説
言語特性を考慮に入れて、語の範囲を返します。
インデックスがレシーバーの文字数より多ければNSRangeExceptionを起こします。
日本語だったら、平仮名の範囲や漢字の範囲など。
返り値
( NSRange )
範囲
引数
( unsigned )index
番号
フレームワーク
ApplicationKit
クラス
NSAttributedStringAdditions
Instance Methods
使用可能
10.0
参照
- nextWordFromIndex:forward:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender {//開けるファイル拡張子の配列 NSArray *fileTypes = [ NSArray arrayWithObject : @"rtf" ]; //OpenPanelを作る NSOpenPanel *opPanel = [ NSOpenPanel openPanel ]; NSAttributedString *aString; //OpenPanelの結果のボタン番号 int opRet; NSRange rng; //OpenPanelでファイル選択 opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Documents" //どのどのファイルを選択しておくか types : fileTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら aString = [[NSAttributedString allocWithZone:[self zone]] initWithPath:[opPanel filename] documentAttributes:NULL]; rng = [aString doubleClickAtIndex:1]; NSLog([NSString stringWithFormat:@"%d,%d",rng.location,rng.length]); } } @end