iOS 日常錯誤匯總--持續(xù)更新中。。。

日常編程錯誤

  1. 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]
  1. cannot jump from switch statement to this case label
    switch-case 中是不可以定義對象的,否則就會報錯,添加大括號可以修復(fù)錯誤
  2. 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'
  3. static declaration follows non-static declaration
    原因是 調(diào)用靜態(tài)函數(shù)沒有先聲明,就是定義在調(diào)用之后。調(diào)用之前聲明一下這個函數(shù)。
  4. Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "CGColorController" nib but the view outlet was not set.'
    加載Nib錯誤
  5. 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)];
    }

日常警告

  1. ld: warning: directory not found for option
    警告原因:將文件夾刪除,但是之前添加過該路徑
    解決方法 :打開項目target ->build setting -> library search pathframework search path -> 移除已經(jīng)無效的路徑

  2. warning: no rule to process file
    警告原因:.h文件出現(xiàn)在target -> build phases -> compile sources
    解決方法: 移除即可

  3. xx is missing from working copy
    警告原因:刪除不用圖片后圖片后
    解決方法:Xcode - Preferences -> Source -> Enable Source Control 禁用Xcode 自帶 Source Control Manager

  4. 屏蔽編譯器警告

#pragma clang diagnostic push
#pragma clang diagnostic ignored ""
//代碼段
#pragma clang diagnostic pop

打包錯誤

  1. 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專用密碼 -> 生成密碼 -> 用新生成的密碼登錄
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容