首页 > 技术文章 > 异常崩溃总结 iOS

huangzs 2020-09-09 20:11 原文

1.Unrecognized instance class:NSTaggedPointerString and selector:string

示例:

self.mTitleLabel.attributedText = [aModel.activeName getAttributeStrWithFont:kFontRatio(14) lineSpace:6];

原因:

调用NSAttributedString方法,字符串不能传nil

解决:

self.mTitleLabel.attributedText = [aModel.activeName?:@"" getAttributeStrWithFont:kFontRatio(14) lineSpace:6];

 

2.data parameter is nil

示例:

NSDictionary * aDict = [NSJSONSerialization JSONObjectWithData:payloadData options:NSJSONReadingAllowFragments error:nil];

原因:

JSONObjectWithData传的字符串需要非空

解决:

if (!payloadData) {
        return;
    }
    NSError *error=nil;
    NSDictionary * aDict = [NSJSONSerialization JSONObjectWithData:payloadData options:NSJSONReadingAllowFragments error:&error];
    if (error) {
        return;
    }

 

3.

 

 

 

推荐阅读