ios9 新關鍵字 __kindof 等(etc) 小結

首先__kindof:規定參數爲UITableViewCell(舉例)這個類或者其子類。好比說一個NSArray<UIView *>*,若是不加__kindof,這個數組只能有UIView,即使是其子類也不行。而加了的話,傳入UIImageView或者UIButton之類的不會有問題。
__typeof會返回對應的類型。html

 

if marked as __kindof,  that the compiler won't complain if you try to access ones of its elements, and store the result in a variable who's type is UIView or one of its subclasses.ios

 

參考連接:objective-c

1.https://happyteamlabs.com/blog/how-to-use-__kindof-in-objective-c/swift

2.https://stackoverflow.com/questions/31399208/ios-kindof-nsarray/33013094#33013094數組

3.http://www.jianshu.com/p/3f73e696dd4dapp

4.http://www.itstrike.cn/Question/b06eefce-1d13-4ace-a8db-a93e36fe2634.htmlcode

5.https://www.infoq.com/articles/whats-new-ios9-swift-objchtm

相關文章
相關標籤/搜索