NSString+NSMutableString+NSValue+NSAraay用法汇总
2010-09-16 23:54:00 来源:WEB开发网从目录搜索扩展名为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);
*/
/*-------- 在已有字符串中按照所给出范围和长度删除字符------*/
Tags:NSString NSMutableString NSValue
编辑录入:coldstar [复制链接] [打 印]更多精彩
赞助商链接