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

NSString+NSMutableString+NSValue+NSAraay用法汇总

 2010-09-16 23:54:00 来源:WEB开发网   
核心提示://NSArray *array = [[NSArray alloc] initWithObjects:@"One",@"Two",@"Three",@"Four",nil];self.dataArray = array;[array re

//NSArray *array = [[NSArray alloc] initWithObjects:

@"One",@"Two",@"Three",@"Four",nil];

self.dataArray = array;

[array release];

//- (unsigned) Count;数组所包含对象个数;

NSLog(@"self.dataArray cound:%d",[self.dataArray count]);

//- (id) objectAtIndex: (unsigned int) index;获取指定索引处的对象;

NSLog(@"self.dataArray cound 2:%@",[self.dataArray objectAtIndex:2]);

/*-------------------------- 从一个数组拷贝数据到另一数组(可变数级)----------------------------*/

//arrayWithArray:

//NSArray *array1 = [[NSArray alloc] init];

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

NSArray *array = [NSArray arrayWithObjects:

@"a",@"b",@"c",nil];

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

MutableArray = [NSMutableArray arrayWithArray:array];

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

array1 = [NSArray arrayWithArray:array];

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

//Copy

//id obj;

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

NSArray *oldArray = [NSArray arrayWithObjects:

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

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

for(int i = 0; i < [oldArray count]; i++)

{

obj = [[oldArray objectAtIndex:i] copy];

[newArray addObject: obj];

}

//

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

[newArray release];

//快速枚举

//NSMutableArray *newArray = [[NSMutableArray alloc] init];

NSArray *oldArray = [NSArray arrayWithObjects:

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

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

for(id obj in oldArray)

{

[newArray addObject: obj];

}

//

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

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

Tags:NSString NSMutableString NSValue

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