Sean's Note: [讀書筆記] Effective Objective-C - Chapter4

2015年2月11日 星期三

[讀書筆記] Effective Objective-C - Chapter4

4. Protocols and Categories

Item 23: Use Delegate and Data Source Protocols for Interobject Communication 

  1. A delegate property will always be defined using the weak attribute.
  2. If required, implement the bitfield structure approach to cache which methods a delegate responds to from the protocol. 

Item 24: Use Categories to Break Class Implementation into Manageable Segments

  1. Use categories to split a class implementation into more manageable fragments.
  2. Create a category called Private to hide implementation detail of methods that should be considered as private.

Item 25: Always Prefix Category Names on Third-Party Classes

Item 26: Avoid Properties in Categories

  1. Can use associated objects instead, but not good enough.

Item 27: Use the Class-Continuation Category to Hide Implementation Detail

Item 28: Use a Protocol to Provide Anonymous Objects 

沒有留言:

張貼留言