ios

常见错误[不定期更新]

2016-08-26  本文已影响133人  CoderZb

(一)利用AFN请求数据时的错误提示1:

"Request failed: unacceptable content-type: text/html"
101.34.gif
 manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
101.35.gif
header('Content-type: text/json');
101.36.gif

(二)利用AFN请求数据时的错误提示2:

"Request failed: unacceptable content-type: text/json"
101.38.gif

(三)利用AFN请求数据,控制台输出的内容有乱码

   // responseObject为json数据。这里将json数据先转为NSData,
    NSData *JsonToData = [NSJSONSerialization dataWithJSONObject:responseObject options:NSJSONWritingPrettyPrinted error:nil];
   // 再将NSData转为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;
}

错误提示如下:

Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], 
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-
3512.60.7/UITableView.m:7971

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString  *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];// 从缓存池取出cell
    if(cell == nil){// 缓存池没有cell就自己创建一个cell
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    
    cell.textLabel.text = self.dataSources[indexPath.row];
    
    return cell;
}

(五)真机调试提示 An unknown error occurred.

(六)每次运行模型都会出现这个提示,每次必须clean项目才能运行

9873A504A846DA8BDECC796AE2154CB6.jpg

(七)出现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

错误原因:

解决办法:


<八>出现duplicate symbol OBJC_IVAR$_AS_ZBGrabDetailTableViewTwoCell._words in:

引用错误.png 引用错误的地方.png

还有一种情况就是项目中有重复的文件。


ios真机调试错误 Reason: no suitable image found. Did find


指针类型不匹配

指针类型不匹配.png

修改不可变数组中的值


no such file or directory: '/Users/zhangbin/Desktop/一秒招聘/aSecondjobProject/AS_ZBEmployerOrderEmployerListModel.m'

image.png

[__NSCFNumber length]: unrecognized selector sent to instance 0x类似这个链接的错误


文件引用错误

image.png

报NSScanner: nil string argument错误

image.png

declaration of 'Method' must be imported from module 'ObjectiveC.runtime' before it is required

解决办法:在报错的文件中添加头文件导入头文件 #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
上一篇下一篇

猜你喜欢

热点阅读