NSMutableArray 是 NSArray 的一個子類,所以能夠在任何使用 NSArray 的位置使用 NSMutableArray。數組
除了包含在 NSArray 中的方法,NSMutableArray 還提供了修改數組的方法。spa
//向數組添加對象對象
addObject: 和 insertObject:atIndex: 繼承
//從數組刪除對象rem
removeAllObjects、removeLastObject 和 removeObjectAtIndex: it
//替換數組中的某個對象io
replaceObjectAtIndex:withObject: table
//篩選數組ast
filterUsingPredicate:數據類型
//從新排列數組中的元素
exchangeObjectAtIndex:withObjectAtIndex:、sortUsingComparator:和sortUsingFunction: context:
ps:
數組類 NSArray 和 NSMutableArray 僅能包含對象。
不能將標量數據類型,如 int、long 或者其餘任何不是繼承自 NSObject 的類型插入 NSArray 或 NSMutableArray。