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

NSString+NSMutableString+NSValue+NSAraay用法汇总

 2010-09-16 23:54:00 来源:WEB开发网   
核心提示://快速枚举//for(NSString *filename in direnum)//{// if([[filename pathExtension] isEqualToString:@"jpg"]){// [files addObject:filename];// }//}NSLog(@&quo

//快速枚举

//for(NSString *filename in direnum)

//{

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

// [files addObject:filename];

// }

//}

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

//枚举

NSEnumerator *filenum;

filenum = [files objectEnumerator];

while (filename = [filenum nextObject]) {

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

}

@"b",@"a",@"e",@"d",@"c",@"f",@"h",@"g",nil];

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

NSEnumerator *enumerator;

enumerator = [oldArray objectEnumerator];

id obj;

while(obj = [enumerator nextObject])

{

[newArray addObject: obj];

}

[newArray sortUsingSelector:@selector(compare:)];

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

[newArray release];

/*--------------------------- 切分数组------------------------------*/

//从字符串分割到数组- componentsSeparatedByString:

NSString *string = [[NSString alloc] initWithString:@"One,Two,Three,Four"];

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

NSArray *array = [string componentsSeparatedByString:@","];

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

[string release];

//从数组合并元素到字符串- componentsJoinedByString:

NSArray *array = [[NSArray alloc] initWithObjects:@"One",@"Two",@"Three",@"Four",nil];

NSString *string = [array componentsJoinedByString:@","];

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

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

NSMutableArray

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

/*--------------- 给数组分配容量----------------*/

//NSArray *array;

array = [NSMutableArray arrayWithCapacity:20];

/*-------------- 在数组末尾添加对象----------------*/

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

Tags:NSString NSMutableString NSValue

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