【Foundation-10-4】#import <Foundation/NSArray.h>可变数组,一般
2015-10-12 19:34
489 查看
@interface NSMutableArray :
NSArray
- (void)addObject:(id)anObject;
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index;
- (void)removeLastObject;
- (void)removeObjectAtIndex:(NSUInteger)index;
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCapacity:(NSUInteger)numItems
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCoder:(NSCoder *)aDecoder
NS_DESIGNATED_INITIALIZER;
@end
@interface NSMutableArray (NSMutableArrayCreation)
+ (instancetype)arrayWithCapacity:(NSUInteger)numItems;
+ (NSMutableArray *)arrayWithContentsOfFile:(NSString *)path;
+ (NSMutableArray *)arrayWithContentsOfURL:(NSURL *)url;
- (NSMutableArray *)initWithContentsOfFile:(NSString *)path;
- (NSMutableArray *)initWithContentsOfURL:(NSURL *)url;
@end
NSArray
- (void)addObject:(id)anObject;
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index;
- (void)removeLastObject;
- (void)removeObjectAtIndex:(NSUInteger)index;
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCapacity:(NSUInteger)numItems
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCoder:(NSCoder *)aDecoder
NS_DESIGNATED_INITIALIZER;
@end
NSMutableArray *arr = [NSMutableArray array];//一般用这个就行了 NSMutableArray *arr2 = [[NSMutableArray alloc]initWithCapacity:0];//数组大小 // NSMutableArray *arr3 = [NSMutableArray alloc]initWithCoder:@""]; [arr addObject:@"1"]; [arr addObject:@"2"]; [arr addObject:@"3"]; [arr insertObject:@"4" atIndex:1]; [arr removeLastObject]; [arr removeObjectAtIndex:0]; [arr replaceObjectAtIndex:0 withObject:@"??"]; NSLog(@"%@",arr);
@interface NSMutableArray (NSMutableArrayCreation)
+ (instancetype)arrayWithCapacity:(NSUInteger)numItems;
+ (NSMutableArray *)arrayWithContentsOfFile:(NSString *)path;
+ (NSMutableArray *)arrayWithContentsOfURL:(NSURL *)url;
- (NSMutableArray *)initWithContentsOfFile:(NSString *)path;
- (NSMutableArray *)initWithContentsOfURL:(NSURL *)url;
NSString *path = [[NSBundle mainBundle]pathForResource:@"testArray" ofType:@"plist"]; NSMutableArray *arr0 = [NSMutableArray arrayWithCapacity:0]; arr0 = [NSMutableArray arrayWithContentsOfFile:path]; // 类方法 // arr0 = [[NSMutableArray alloc]initWithContentsOfFile:path]; //实例方法 NSLog(@"%@",arr0);获取URL 类似
@end
相关文章推荐
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- python遗产
- 类的专有方法(__del__)
- Java基础知识总结
- 专题:前端性能研究
- Java TreeMap 源码解析
- 【置顶] signal信号捕捉
- hibernate sql查询
- lintcode 容易题:Insert Node in a Binary Search Tree 在二叉查找树中插入节点
- 从C++prime的习题开始做起
- Android5.1源码Xposed框架编译
- linux 程序开发打印 debug()
- 高并发解决方案
- 《机器学习实战》笔记之十一——使用Apriori算法进行关联分析
- 专访范钢:重构不是阳春白雪的高端玩意,而是码农编程利器(转)
- 树莓派版的家用NAS服务器
- 星云大师十句话,受用一生
- hihoCoder #1241 Best Route in a Grid
- Python import module 的几种情况
- Android:Web App,Hybrid App,Native App之web:Android和javaScript相互调用