持續(xù)更新中。。。另一篇<iOS 總結(jié)遇到的各種坑兒>
一、集合返回枚舉對(duì)象
- (NSEnumerator *)keyEnumerator {
return [array objectEnumerator];
}
- (NSEnumerator *)reverseKeyEnumerator {
return [array reverseObjectEnumerator];
}
以上的NSEnumerator :
官方解釋?zhuān)?NSEnumerator
is an abstract class, instances of whose subclasses enumerate collections of other objects, such as arrays and dictionaries.
All creation methods are defined in the collection classes—such as NSArray
, NSSet
, and NSDictionary
—which provide special NSEnumerator
objects with which to enumerate their contents. For example, NSArray
has two methods that return an NSEnumerator
object: [objectEnumerator](apple-reference-documentation://hcQ1W7GHf_) and [reverseObjectEnumerator](apple-reference-documentation://hc41c-0oVQ). NSDictionary
also has two methods that return an NSEnumerator
object: [keyEnumerator](apple-reference-documentation://hc-hIDsaE8) and [objectEnumerator](apple-reference-documentation://hc7rb-nJ5L). These methods let you enumerate the contents of a dictionary by key or by value, respectively.
You send [nextObject](apple-reference-documentation://hcp9Mbgcbv) repeatedly to a newly created NSEnumerator
object to have it return the next object in the original collection. When the collection is exhausted, nil
is returned. You cannot “reset” an enumerator after it has exhausted its collection. To enumerate a collection again, you need a new enumerator.
The enumerator subclasses used by NSArray
, NSDictionary
, and NSSet
retain the collection during enumeration. When the enumeration is exhausted, the collection is released.
**Note**In Objective-C, it is not safe to modify a mutable collection while enumerating through it. Some enumerators may currently allow enumeration of a collection that is modified, but this behavior is not guaranteed to be supported in the future.
官方解釋譯文:
NSEnumerator是一個(gè)抽象類(lèi),其子類(lèi)枚舉其他對(duì)象(如數(shù)組和字典)的集合的實(shí)例。
所有創(chuàng)建方法都在集合類(lèi)中定義,例如NSArray,NSSet和NSDictionary,它們提供用于枚舉其內(nèi)容的特殊NSEnumerator對(duì)象。例如,NSArray有兩個(gè)返回NSEnumerator對(duì)象的方法:objectEnumerator和reverseObjectEnumerator。 NSDictionary還有兩個(gè)返回NSEnumerator對(duì)象的方法:keyEnumerator和objectEnumerator。這些方法可以分別按鍵或值枚舉字典的內(nèi)容。
您將nextObject重復(fù)發(fā)送到新創(chuàng)建的NSEnumerator對(duì)象,以使其返回原始集合中的下一個(gè)對(duì)象。收集用盡時(shí),返回零。枚舉器耗盡其收集后,您無(wú)法“重置”。要再次枚舉一個(gè)集合,您需要一個(gè)新的枚舉器。
NSArray,NSDictionary和NSSet使用的枚舉子子類(lèi)在枚舉期間保留集合。枚舉耗盡時(shí),集合被釋放。
注意
在Objective-C中,通過(guò)枚舉來(lái)修改可變集合是不安全的。一些枚舉者可能現(xiàn)在允許枚舉一個(gè)被修改的集合,但這種行為不能保證在將來(lái)被支持。
二、ios字體
ios9以上 默認(rèn)字體是 蘋(píng)方字體
ios8 默認(rèn)字體是 常州華文的Heiti SC。