Objective-C中数组的使用
来源:互联网 发布:淘宝女内增高鞋 编辑:程序博客网 时间:2024/06/06 05:23
//创建不变数组
NSArray *array=[NSArrayarrayWithObjects:@"one",@"two",@"three",nil];
NSLog(@"%@",array);
NSArray *array1=[[NSArrayalloc]initWithObjects:@"one",@"two",@"three",nil];
NSLog(@"%@",array1);
//取数组中的元素
NSLog(@"%@",[arrayobjectAtIndex:2]);
//输出数组中元素的个数
NSLog(@"%lu",[arraycount]);
//使用枚举输出数组元素
NSEnumerator *enumerator;
enumerator=[arrayobjectEnumerator];
id obj;
while(obj=[enumerator nextObject])
{
NSLog(@"I found %@",obj);
}
//使用枚举器倒着输出
NSEnumerator *enumerator1;
enumerator1=[arrayreverseObjectEnumerator];
id obj1;
while(obj1=[enumerator1 nextObject])
{
NSLog(@"I found %@",obj1);
}
//快速枚举
for(id obj in array)
{
NSLog(@"I found %@",obj);
}
//创建可变数组
NSMutableArray *marray=[NSMutableArrayarrayWithCapacity:17];
[marrayaddObject:@"thing"];
[marrayaddObject:@"one"];
NSLog(@"%@",marray);
//删除元素
[marrayremoveObjectAtIndex:0];
NSLog(@"%@",marray);
//插入元素
[marrayinsertObject:@"two"atIndex:1];
NSLog(@"%@",marray);
//替换元素
[marray replaceObjectAtIndex:0withObject:@"ten"];
NSLog(@"%@",marray);
- Objective-C中数组的使用
- objective-c数组使用小结
- objective-c 中对于类的使用
- Objective-C中NSValue的使用
- Objective-C中NSValue的使用
- objective-c 中NSDictionary的使用
- Objective-c中线程NSThread的使用
- Objective-C中字符串的使用
- Objective-C中字典的使用
- Objective-C中NSValue的使用
- objective-c中self的使用
- Objective-C中NSValue的使用
- Objective-C 中 @property的使用
- Objective-C中NSString的使用
- Objective-C开发中Clang的使用
- Objective-C的数组的初始化完成后再使用
- Objective-C中关于数组操作常用的方法
- Objective C中数组排序几种情况的总结
- Linux Oracle服务启动&停止脚本与开机自启动
- 每天一条Linux命令 mkdir命令(10)
- Linux内存缺页错误处理
- [C++_8]继承_2
- 在驱动和应用程序间共享内存
- Objective-C中数组的使用
- CSDN引进跨平台开发工具Xamarin 为C#开发者服务
- Apache Rewrite语法
- C# 判断某值在数组中的索引
- Oracle 锁机制(Lock mechanism)
- Objective-C中字典的使用
- UVA11039 Building Designing
- Html5游戏开发攻略(Canvas设置篇)
- iOS开发 内存使用陷阱