Adopted Protocols
Tasks
Creating an Array
+ array
-
+ arrayWithArray:
--
-
+ arrayWithContentsOfFile:
--从文件中初始化数组
+ arrayWithContentsOfURL:
-
+ arrayWithObject:
--只能初始化一个元素
-
+ arrayWithObjects:
--初始化多个元素
+ arrayWithObjects:count:
Initializing an Array
– init
– initWithArray:
– initWithArray:copyItems:
– initWithContentsOfFile:
– initWithContentsOfURL:
– initWithObjects:
– initWithObjects:count:
Querying an Array
-
– containsObject:
-- 是否包含字符串
-
– count
--获取元素中的个数
– getObjects:range:
– firstObject
– lastObject
-
– objectAtIndex:
--访问数组中的某个元素
– objectAtIndexedSubscript:
– objectsAtIndexes:
– objectEnumerator
– reverseObjectEnumerator
-
– getObjects:
Deprecated in OS X v10.6
Finding Objects in an Array
– indexOfObject:
– indexOfObject:inRange:
– indexOfObjectIdenticalTo:
– indexOfObjectIdenticalTo:inRange:
– indexOfObjectPassingTest:
– indexOfObjectWithOptions:passingTest:
– indexOfObjectAtIndexes:options:passingTest:
– indexesOfObjectsPassingTest:
– indexesOfObjectsWithOptions:passingTest:
– indexesOfObjectsAtIndexes:options:passingTest:
– indexOfObject:inSortedRange:options:usingComparator:
Sending Messages to Elements
– makeObjectsPerformSelector:
– makeObjectsPerformSelector:withObject:
– enumerateObjectsUsingBlock:
– enumerateObjectsWithOptions:usingBlock:
– enumerateObjectsAtIndexes:options:usingBlock:
Comparing Arrays
Deriving New Arrays
-
– arrayByAddingObject:
--追加数组的内容
– arrayByAddingObjectsFromArray:
– filteredArrayUsingPredicate:
– subarrayWithRange:
Sorting
– sortedArrayHint
– sortedArrayUsingFunction:context:
– sortedArrayUsingFunction:context:hint:
– sortedArrayUsingDescriptors:
– sortedArrayUsingSelector:
– sortedArrayUsingComparator:
– sortedArrayWithOptions:usingComparator:
Working with String Elements
-
– componentsJoinedByString:
-- 数组-->字符串
Creating a Description
– description
– descriptionWithLocale:
– descriptionWithLocale:indent:
– writeToFile:atomically:
– writeToURL:atomically:
Collecting Paths
Key-Value Observing
– addObserver:forKeyPath:options:context:
– removeObserver:forKeyPath:
– removeObserver:forKeyPath:context:
– removeObserver:fromObjectsAtIndexes:forKeyPath:context:
– addObserver:toObjectsAtIndexes:forKeyPath:options:context:
– removeObserver:fromObjectsAtIndexes:forKeyPath:
Key-Value Coding
NSMutableArray
Tasks
Creating and Initializing a Mutable Array
Adding Objects
Removing Objects
– removeAllObjects
– removeLastObject
– removeObject:
– removeObject:inRange:
– removeObjectAtIndex:
– removeObjectsAtIndexes:
– removeObjectIdenticalTo:
– removeObjectIdenticalTo:inRange:
– removeObjectsInArray:
– removeObjectsInRange:
-
– removeObjectsFromIndices:numIndices:
Deprecated
in OS X v10.6
Replacing Objects
– replaceObjectAtIndex:withObject:
– setObject:atIndexedSubscript:
– replaceObjectsAtIndexes:withObjects:
– replaceObjectsInRange:withObjectsFromArray:range:
– replaceObjectsInRange:withObjectsFromArray:
– setArray: