其實以下這些 Mac Programming 應該也適用,都是很基本的東西,只是作個筆記。
Run Static Analyzer
Static Analyzer 可以用來抓出潛在的記憶體洩漏風險、多餘的變數等問題。Xcode 有內建一個 Static Analyzer,是基於 Clang Static Analyzer 修改來的。直接就能使用!或者也可以照著 Clang Static Analyzer 網站上建議的,手動安裝他們提供的最新版。
執行的方法為 Build / Build And Analyze。
Set Global Breakpoint on objc_exception_throw
意思就是說在丟出 Exception 的時候中斷程式,光用想像的就覺得超實用的啊!
新增的方法是到 Run / Show / Breakpoints,在 “Double-Click for Symbol” 上點兩下,然後填入 objc_exception_throw12。
Treat Warnings as Errors
Warnings 表示沒有 Compile Error,但是卻有 Runtime Error 的風險,所以建議勾選這個選項。
這個選項的位置在 Project / Edit Project Settings,Build 頁籤當中。
Use LLVM Compiler if Possible
LLVM 編譯器在 Xcode 3.2 當中已內建,穩定程度已經足夠,並且預期能夠產生比 GCC 更小的可執行檔、更快的執行速度,不過實際效果仍然要以測試為準。LLVM GCC 是 GCC-compatible 的 LLVM,若無必要可以直接選用 LLVM compiler。Xcode 3.2 內建的 LLVM compiler 同樣比較舊,需要的話也可以自行編譯最新版 LLVM compiler 來使用。
這個選項的位置在 Project / Edit Project Settings,Build 頁籤當中,名稱叫做 “C/C++ Compiler Version”。
Use Instruments for Profiling
Instruments 是包含於 Xcode 之中的一個 App,它可以用來記錄、分析程式的運作,有助於最佳化程式效能。3