
日常編程錯誤
- Multiple methods named 'count' found with mismatched result, parameter type
錯誤概述:發(fā)現(xiàn)多個參數(shù)類型和返回值不相同的count方法
錯誤發(fā)生場景:UITableView dataSource numberOfRowsInSection方法使用二維數(shù)組調(diào)用方式獲取Rows行數(shù)
[[self.dataArray objectAtIndex:section] count]
objectAtIndex 返回的是個id類型,id類型調(diào)用了count方法,編譯器遍歷所有的可見頭的count方法,編譯器會找到多個定義,返回值不一樣的,參數(shù)類型不一樣的,比如count方法在NSArray,NSSet等類上也有實現(xiàn),或者自己自定義的count 方法。編譯器不知道該使用哪個方法,強(qiáng)制指定objectAtIndex的值類型,告訴編譯器要調(diào)用指定的count方法
[(NSArray *)[self.dataArray objectAtIndex:section] count]
-
cannot jump from switch statement to this case label
switch-case中是不可以定義對象的,否則就會報錯,添加大括號可以修復(fù)錯誤 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid nib registered for identifier (Sunmesing.XMXMiddleMainTableViewCell) - nib must contain exactly one top level object which must be a UITableViewCell instance'- static declaration follows non-static declaration
原因是 調(diào)用靜態(tài)函數(shù)沒有先聲明,就是定義在調(diào)用之后。調(diào)用之前聲明一下這個函數(shù)。 - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "CGColorController" nib but the view outlet was not set.'
加載Nib錯誤 - Assertion failure in -[PSTableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UITableView.m:9655
if (cell == nil) { // 報錯原因 此處沒有判空
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ClassToString(UITableViewCell)];
}
日常警告
ld: warning: directory not found for option
警告原因:將文件夾刪除,但是之前添加過該路徑
解決方法 :打開項目target->build setting->library search path或framework search path-> 移除已經(jīng)無效的路徑warning: no rule to process file
警告原因:.h文件出現(xiàn)在target->build phases->compile sources中
解決方法: 移除即可xx is missing from working copy
警告原因:刪除不用圖片后圖片后
解決方法:Xcode - Preferences -> Source -> Enable Source Control禁用Xcode 自帶Source Control Manager屏蔽編譯器警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored ""
//代碼段
#pragma clang diagnostic pop
打包錯誤
- application loader 打包報
Please sign in with an app-specific password. You can create one at appleid.apple.com.錯
原因: 開啟了二次認(rèn)證
解決方案:關(guān)閉二次認(rèn)證
或登錄蘋果官網(wǎng),找到安全選項-> app專用密碼 -> 生成密碼 -> 用新生成的密碼登錄