nextWordFromIndex:forward:
最初の文字のインデックスを返します
-(unsigned int)nextWordFromIndex:(unsigned)index: forward:(BOOL)flag:
解説
指定した文字の前の単語、または後の単語の最初の文字のインデックスを返します。
返り値
( unsigned int )
整数値
引数
( unsigned )index
番号
( BOOL )flag
前かYES/NO
フレームワーク
ApplicationKit
クラス
NSAttributedStringAdditions
Instance Methods
使用可能
10.1
参照
- lineBreakBeforeIndex:withinRange:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender {//開けるファイル拡張子の配列 NSArray *fileTypes = [ NSArray arrayWithObject : @"rtf" ]; //OpenPanelを作る NSOpenPanel *opPanel = [ NSOpenPanel openPanel ]; NSAttributedString *aString; //OpenPanelの結果のボタン番号 int opRet; unsigned lb; //OpenPanelでファイル選択 opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Documents" //どのどのファイルを選択しておくか types : fileTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら aString = [[NSAttributedString allocWithZone:[self zone]] initWithPath:[opPanel filename] documentAttributes:NULL]; lb = [aString nextWordFromIndex:1 forward:YES]; NSLog([NSString stringWithFormat:@"%d",lb]); } } @end