1威鹿、設(shè)置斷點(diǎn)
當(dāng)在模擬器上程序崩潰時剃斧,斷點(diǎn)通常直接跳到了main函數(shù)中,無法判斷具體哪一行代碼開始崩潰忽你,添加一個All Exceptions斷點(diǎn)就可以了幼东。
2、工程報如下錯誤:
fatal error: file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/.../xxx.h' has been modified since theprecompiled header '/Users/Lycros/Library/Developer/Xcode/DerivedData/ModuleCache/.../***.pch.pch' was built
解決方式如下:
Quit Xcode and remove everything in the module cache located here:
~/Library/Developer/Xcode/DerivedData/ModuleCache (刪除該文件中的緩存即可)
The cache that was built with a previous version of Xcode is invalid for this version of Xcode and SDK, and that is causing your error
3科雳、iOS模擬器鍵盤增加中文輸入
(1)在模擬器設(shè)置中系統(tǒng)語言設(shè)置為中文根蟹,鍵盤中添加中文鍵盤
(2)Xcode菜單項(xiàng) --> Product --> Scheme --> Edit Scheme -->? Run --> Option --> Application Region 設(shè)置為 “中國”
(3)Command+shift+k連接電腦鍵盤、Command+shift+k彈出后收起模擬器鍵盤
4糟秘、關(guān)于inputView的坑
自己實(shí)現(xiàn)了一個CommentInputView類简逮,在使用該類時,實(shí)例名稱寫為了inputView尿赚,結(jié)果調(diào)試程序在觸發(fā)一個長按手勢后散庶,總是莫名其妙彈出一個全面的背景視圖,之后inputView設(shè)置為第一響應(yīng)者時凌净,提示父控制器類型不對然后崩潰悲龟。最終排查發(fā)現(xiàn):UIResponder類也有一個屬性叫inputView,The custom input view to display when the receiver becomes the first responder. (read-only)冰寻。明白了须教,CommentInputView繼承自UIResponder,因此本身已經(jīng)存在inputView屬性斩芭,而自己的變量命名與系統(tǒng)變量命名沖突了轻腺。
5、模擬內(nèi)存警告
如果是在模擬器上划乖,可以直接使用模擬器快捷鍵Cmd+M;
也可以通過代碼主動觸發(fā)內(nèi)存警告:
[[UIApplication sharedApplication] performSelector:@selector(_performMemoryWarning)];
6约计、特殊注釋
// TODO:待實(shí)現(xiàn)的功能
// FIXME:待修復(fù)BUG
// ???:有疑問的代碼
// !!!:待改進(jìn)
// MARK:突出標(biāo)記的代碼