attributesAtIndex:longestEffectiveRange:inRange:
INDEX>Foundation>NSAttributedString
番号で属性と適用される範囲を返します
-(NSDictionary *)attributesAtIndex:(unsigned)index: longestEffectiveRange:(NSRangePointer)aRange: inRange:(NSRange)rangeLimit:
解説
番号で属性と適用される範囲を返します。
返り値
( NSDictionary * )
辞書
引数
( unsigned )index
番号
( NSRangePointer )aRange
適用される範囲のポインタ
( NSRange )rangeLimit
最大範囲
フレームワーク
Foundation
クラス
NSAttributedString
Instance Methods
使用可能
10.0
iOS3.2
参照
- attributesAtIndex:longestEffectiveRange:inRange:
例文
#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 bRange; //OpenPanelでファイル選択 opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Documents" //どのどのファイルを選択しておくか types : fileTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら aString = [[NSAttributedString allocWithZone:[self zone]] initWithPath:[opPanel filename] documentAttributes:NULL]; [image lockFocus]; [aString drawInRect:[image bounds]]; [image unlockFocus]; NSLog([[aString attributesAtIndex:1 longestEffectiveRange:&bRange inRange:NSMakeRange(0,5) ] description]); NSLog([NSString stringWithFormat:@"%d,%d",bRange.location,bRange.length]); } } @end