iOS开发过程中遇到的新奇玩意儿

持续更新中。。。另一篇

一、集合返回枚举对象

- (NSEnumerator *)keyEnumerator {
    
    return [array objectEnumerator];
}

- (NSEnumerator *)reverseKeyEnumerator {
    
    return [array reverseObjectEnumerator];
}

以上的NSEnumerator :

官方解释:
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是一个抽象类,其子类枚举其他对象(如数组和字典)的集合的实例。
所有创建方法都在集合类中定义,例如NSArray,NSSet和NSDictionary,它们提供用于枚举其内容的特殊NSEnumerator对象。例如,NSArray有两个返回NSEnumerator对象的方法:objectEnumerator和reverseObjectEnumerator。 NSDictionary还有两个返回NSEnumerator对象的方法:keyEnumerator和objectEnumerator。这些方法可以分别按键或值枚举字典的内容。
您将nextObject重复发送到新创建的NSEnumerator对象,以使其返回原始集合中的下一个对象。收集用尽时,返回零。枚举器耗尽其收集后,您无法“重置”。要再次枚举一个集合,您需要一个新的枚举器。
NSArray,NSDictionary和NSSet使用的枚举子子类在枚举期间保留集合。枚举耗尽时,集合被释放。
注意
在Objective-C中,通过枚举来修改可变集合是不安全的。一些枚举者可能现在允许枚举一个被修改的集合,但这种行为不能保证在将来被支持。

二、ios字体

ios9以上 默认字体是 苹方字体
ios8 默认字体是 常州华文的Heiti SC。

三、报黄提醒

define FLYRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)

你可能感兴趣的:(iOS开发过程中遇到的新奇玩意儿)