Protocol/Delegate
Protocol 是 Delegate 的介面,定義了 Delegate 必須實作什麼,用其他語言的概念來說明,Delegate 就像是 Callback。Delegate 不一定需要 Protocol,不過最好是要有,程式看起來會比較清楚。
Block
Block 是 iOS 4 以後加入的 Syntax Sugar,它其實就是 anonymous function,我覺得這應該可以用來取代比較沒有復用性的 Delegate,有的時候採用 Block 的寫法能讓程式更清楚易懂,例如 UIView 的 beginAnimation vs. animateWithDuration 兩種寫法我就覺得 Block 方便太多了。
Block 的缺點是有時候不能下中斷點,例如 iPhone Simulator + GDB 的情況,Debug 起來比較不方便,不過我猜也有可能是我沒設定好之類的。
Notification Center
Notification Center 就是 Event/Listener,iOS 中共有四種 Notification Center,分別是 NSNotificationCenter、NSDistributedNotificationCenter、DarwinNotificationCenter 及 TelephonyNotificationCenter。這很適合用來處理全域事件、降低物件耦合性,例如在自定類別中呼叫 UIViewController 更新畫面。
Base SDK? iOS Deployment Target?
Base SDK 是你的 App 可以支援的最新 SDK 版本,而 iOS Deployment Target 是你的 App 可以支援的最老 SDK 版本,所以 Base SDK 最好設定為 Latest SDK。
[UIDevice uniqueIdentifier] is not UUID
它不是 UUID,雖然在 Simulator 中它是,但是在 Device 中則是 UDID,也就是你在 Xcode Organizer 看到的 Identifier。