NSMutableString:replaceCharactersInRange:withString:
Home 目次>Foundation>NSMutableString

replaceCharactersInRange:withString:

変更可能な文字列の指定した範囲の文字列を別の文字列と置き換えます


-(void) replaceCharactersInRange:(NSRange)aRange
   withString:(NSString *)aString


【返り値】
   voidなし
【パラメータ】
   aRange置き換えられる範囲
   aString置き換える文字


【解説】

変更可能な文字列の指定した範囲の文字列を別の文字列(aString)と置き換えます。
置き換えられる範囲(aRange)がレシーバの範囲を越えたら、NSRangeExceptionを起こします。



【例文】


#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSMutableString *muStr = [NSMutableString stringWithCapacity:10];

[muStr appendString:@"abcdefghijklmnopqrstuvexyz"];
[muStr replaceCharactersInRange:NSMakeRange(4,5) withString:@"xxxxxxx"];
[info setStringValue:muStr];
}

@end


(C) 2000-2007 Satoshi Oomori.
[Apple]

Google
Webwww.oomori.com
Apple_Store_40x120

[ad:Usual day in Japan]

この記事を評価してください。 

良い 

間違いがある 説明がわかりにくい 例文がわかりにくい  

Home 目次>Foundation>NSMutableString
修正日2006.12.26