牛骨文教育服务平台(让学习变的简单)
博文笔记

iOS基础:NSArray常用方法

创建时间:2016-04-22 投稿人: 浏览次数:768

一、NSArray常用方法

//创建array

+ (instancetype)array;

+ (instancetype)arrayWithObject:(ObjectType)anObject;

+ (instancetype)arrayWithArray:(NSArray<ObjectType> *)array;

//获取Array相应的内容

[array lastObject];

[array firstObject];

NSUInteger count = array.count;

- (id)objectAtIndex:(NSUInteger)index

- (NSUInteger)indexOfObject:(id)anObject;

- (NSString *)componentsJoinedByString:(NSString *)separator;


二、NSMutableArray常用方法

//增

- (void)addObject:(id)anObject;

- (void)insertObject:(id)anObject atIndex:(NSUInteger)index;

//删

- (void)removeLastObject;

- (void)removeObjectAtIndex:(NSUInteger)index;

- (void)removeAllObjects;

//改

- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;

- (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;






声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。