WEB开发网
开发学院手机开发iPhone 开发 NSString+NSMutableString+NSValue+NSAraay用法汇... 阅读

NSString+NSMutableString+NSValue+NSAraay用法汇总

 2010-09-16 23:54:00 来源:WEB开发网   
核心提示:/*//deleteCharactersInRange:NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];[String1 deleteCharacters

/*

//deleteCharactersInRange:

NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];

[String1 deleteCharactersInRange:NSMakeRange(0, 5)];

NSLog(@"String1:%@",String1);

/*--------在已有字符串后面在所指定的位置中插入给出的字符串------*/

//-insertString: atIndex:

NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];

[String1 insertString:@"Hi! " atIndex:0];

NSLog(@"String1:%@",String1);

/*--------将已有的空符串换成其它的字符串------*/

//-setString:

NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];

[String1 setString:@"Hello Word!"];

NSLog(@"String1:%@",String1);

/*--------按照所给出的范围,和字符串替换的原有的字符------*/

//-setString:

NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];

[String1 replaceCharactersInRange:NSMakeRange(0, 4) withString:@"That"];

NSLog(@"String1:%@",String1);

/*-------------判断字符串内是否还包含别的字符串(前缀,后缀)-------------*/

//01: 检查字符串是否以另一个字符串开头- (BOOL) hasPrefix: (NSString *) aString;

NSString *String1 = @"NSStringInformation.txt";

[String1 hasPrefix:@"NSString"] = = 1 ? NSLog(@"YES") : NSLog(@"NO");

[String1 hasSuffix:@".txt"] = = 1 ? NSLog(@"YES") : NSLog(@"NO");

//02: 查找字符串某处是否包含其它字符串 - (NSRange) rangeOfString: (NSString *) aString,这一点前面在串中搜索子串用到过;

/**************************************************************************

NSArray

****************************************************************************/

/*---------------------------创建数组 ------------------------------*/

上一页  3 4 5 6 7 8 9 10  下一页

Tags:NSString NSMutableString NSValue

编辑录入:coldstar [复制链接] [打 印]
赞助商链接