(一)利用AFN請求數(shù)據(jù)時(shí)的錯(cuò)誤提示1:
- xcode控制臺(tái)出現(xiàn)的錯(cuò)誤提示:
"Request failed: unacceptable content-type: text/html"
錯(cuò)誤原因:AFNetworking 默認(rèn)不支持text/html
解決方法1.在作者源代碼處添加 @"text/html" 。

101.34.gif
- 解決方法2(推薦).在自己的代碼處加上這句代碼:
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];

101.35.gif
- 解決方法3.讓后臺(tái)人員在后臺(tái)的php代碼中加上這句代碼
header('Content-type: text/json');

101.36.gif
(二)利用AFN請求數(shù)據(jù)時(shí)的錯(cuò)誤提示2:
- xcode控制臺(tái)出現(xiàn)的錯(cuò)誤提示
"Request failed: unacceptable content-type: text/json"
- 錯(cuò)誤原因:前臺(tái)和后臺(tái)都設(shè)置了內(nèi)容類型,去掉其中一個(gè)就行。
- 解決辦法:

101.38.gif
(三)利用AFN請求數(shù)據(jù),控制臺(tái)輸出的內(nèi)容有亂碼
- 解決辦法:
// responseObject為json數(shù)據(jù)。這里將json數(shù)據(jù)先轉(zhuǎn)為NSData,
NSData *JsonToData = [NSJSONSerialization dataWithJSONObject:responseObject options:NSJSONWritingPrettyPrinted error:nil];
// 再將NSData轉(zhuǎn)為NSString
NSString *DataToString = [[NSString alloc] initWithData:JsonToData encoding:NSUTF8StringEncoding];
NSLog(@"%@", DataToString);
- 截圖演示

101.37.gif
(四)未初始化cell
原代碼
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *ID = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
cell.textLabel.text = self.dataSources[indexPath.row];
return cell;
}
錯(cuò)誤提示如下:
Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-
3512.60.7/UITableView.m:7971
- 錯(cuò)誤原因:
- 沒有對cell 為nil的情況進(jìn)行判斷。如果為nil,就直接將數(shù)據(jù)顯示到空的cell的就會(huì)發(fā)生這種情況
- 解決辦法:
- 如果nil為空,就自己創(chuàng)建一個(gè)cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *ID = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];// 從緩存池取出cell
if(cell == nil){// 緩存池沒有cell就自己創(chuàng)建一個(gè)cell
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
}
cell.textLabel.text = self.dataSources[indexPath.row];
return cell;
}
(五)真機(jī)調(diào)試提示 An unknown error occurred.
- 步驟1: /Users/zhangbin/Library/Developer/Xcode/DerivedData/下的文件全部刪除
- 步驟2:重啟電腦即可
(六)每次運(yùn)行模型都會(huì)出現(xiàn)這個(gè)提示,每次必須clean項(xiàng)目才能運(yùn)行

9873A504A846DA8BDECC796AE2154CB6.jpg
- 解決辦法:重置模擬器,即恢復(fù)出廠設(shè)置
(七)出現(xiàn)Assigning to 'id<UINavigationControllerDelegate,UIImagePickerControllerDelegate> _Nullable' from incompatible type 'ViewController *const __strong'這種警告
UIImagePickerController *photoVC = [[UIImagePickerController alloc] init];
photoVC.delegate = self;
photoVC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:photoVC animated:YES completion:nil];

提示警告.png
錯(cuò)誤原因:
- 僅僅設(shè)置了UIImagePickerControllerDelegate協(xié)議頭,但沒有設(shè)置UINavigationControllerDelegate協(xié)議頭
解決辦法:
- 添加UINavigationControllerDelegate協(xié)議頭即可
<八>出現(xiàn)duplicate symbol OBJC_IVAR$_AS_ZBGrabDetailTableViewTwoCell._words in:

引用錯(cuò)誤.png
- 錯(cuò)誤原因:引用文件錯(cuò)誤。將.h的文件寫成了.m

引用錯(cuò)誤的地方.png
還有一種情況就是項(xiàng)目中有重復(fù)的文件。
ios真機(jī)調(diào)試錯(cuò)誤 Reason: no suitable image found. Did find
- 該問題解決方法參考這篇文章解決方法
- 具體解決辦法:把手機(jī)上相應(yīng)的APP刪除,刪除后,xcode clean下,然后重新運(yùn)行,是不是成功了!
- 原因是:因?yàn)槟愕淖C書在上一次安裝到現(xiàn)在安裝失敗這段時(shí)間里證書肯定被重置過,那么兩次的簽名就不一樣了,而你的Bundle identifier ID又是同一個(gè),所以你這次安裝會(huì)失敗。
指針類型不匹配

指針類型不匹配.png
-
解決辦法:把nsinteger前面的*去掉即可
image.png
修改不可變數(shù)組中的值
-
解決辦法:將出現(xiàn)問題的不可變數(shù)組,變?yōu)榭勺償?shù)組
image.png
no such file or directory: '/Users/zhangbin/Desktop/一秒招聘/aSecondjobProject/AS_ZBEmployerOrderEmployerListModel.m'

image.png
- 解決辦法:在如圖的搜索框中,搜索錯(cuò)誤的類,一個(gè)是沒有任何信息的類,一個(gè)是有全路徑的類,將后者刪除即可。鏈接
Snip20170630_123.png
[__NSCFNumber length]: unrecognized selector sent to instance 0x類似這個(gè)鏈接的錯(cuò)誤
- 錯(cuò)誤原因:將NSNumber類型的數(shù)據(jù)賦值給了NSString類型的。例如:這個(gè)NSNumber數(shù)據(jù)是寫入到沙盒的plist文件中的,你從plist文件取出來卻用NSString類型的接收,就會(huì)造成這個(gè)問題。
- 解決辦法:將沙盒plist文件中的NSNumber改為NSString類型?;蛘咧苯訉懺贏PP重裝APP,這樣沙盒的數(shù)據(jù)就沒有額。
文件引用錯(cuò)誤

image.png
- 原因:AS_ZBCommonVC.m文件有問題。我遇到的問題是將其他某個(gè)文件的.m的全部代碼復(fù)制到了AS_ZBCommonVC.m文件中。@implementation后面跟著的類名并沒有和當(dāng)前類(AS_ZBCommonVC)保持一致。@interface后面跟著的類名也沒有和當(dāng)前類(AS_ZBCommonVC)保持一致。
- 解決辦法:將@implementation和@interface后面跟著的類名改為AS_ZBCommonVC,并且導(dǎo)入AS_ZBCommonVC類庫即可,移除沒有更改的類庫。
報(bào)NSScanner: nil string argument錯(cuò)誤

image.png
declaration of 'Method' must be imported from module 'ObjectiveC.runtime' before it is required
解決辦法:在報(bào)錯(cuò)的文件中添加頭文件導(dǎo)入頭文件 #import<objc/runtime.h>
-fembed-bitcode is not supported on versions of iOS prior to 6.0

image.png
解決辦法:
將enable_bitcode的值改為NO即可。 我的這篇文章也有寫過

image.png
Compiling IB documents for earlier than iOS 7 is no longer supported.

Snip20180626_15.png
-
解決辦法:
image.png



