iOS關聯對象源碼解析

前言 關聯對象(AssociatedObject)是一種運用runtime在分類中添加"屬性"的方法。那麼關聯是怎樣實現添加"屬性"的呢? 關聯對象的實現步驟 關聯對象的實現步驟如下: 在分類中.h中聲明一個屬性 在.m中聲明該屬性爲動態加載 @dynamic 實現setter和getter方法 1. @interface UIViewController (Test) @property (
相關文章
相關標籤/搜索