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

NSString+NSMutableString+NSValue+NSAraay用法汇总

 2010-09-16 23:54:00 来源:WEB开发网   
核心提示:从目录搜索扩展名为jpg的文件*///NSFileManager *fileManager = [NSFileManager defaultManager];NSString *home;home = @"../Users/";NSDirectoryEnumerator *direnum;diren

从目录搜索扩展名为jpg的文件

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

//NSFileManager *fileManager = [NSFileManager defaultManager];

NSString *home;

home = @"../Users/";

NSDirectoryEnumerator *direnum;

direnum = [fileManager enumeratorAtPath: home];

NSMutableArray *files = [[NSMutableArray alloc] init];

//枚举

NSString *filename;

while (filename = [direnum nextObject]) {

if([[filename pathExtension] hasSuffix:@"jpg"]){

[files addObject:filename];

}

}

//扩展路径

NSString *Path = @"~/NSData.txt";

NSString *absolutePath = [Path stringByExpandingTildeInPath];

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

NSLog(@"Path:%@",[absolutePath stringByAbbreviatingWithTildeInPath]);

//文件扩展名

NSString *Path = @"~/NSData.txt";

NSLog(@"Extension:%@",[Path pathExtension]);

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

NSMutableString

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

/*---------------给字符串分配容量----------------*/

//stringWithCapacity:

NSMutableString *String;

String = [NSMutableString stringWithCapacity:40];

/*---------------在已有字符串后面添加字符----------------*/

//appendString: and appendFormat:

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

//[String1 appendString:@", I will be adding some character"];

[String1 appendFormat:[NSString stringWithFormat:@", I will be adding some character"]];

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

*/

/*-------- 在已有字符串中按照所给出范围和长度删除字符------*/

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

Tags:NSString NSMutableString NSValue

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