iOS开发 message sent to deallocated instance问题解决
来源:互联网 发布:中国突破第一岛链 知乎 编辑:程序博客网 时间:2024/06/05 05:33
问题
直接看截图吧
解决方法
1. 活动监视器查看APP 进程号PID
2. terminal里查看问题
使用命令 malloc_history PID address |grep address
PID用进程号代替,address用出错地址代替(xcode报错地址)
3. 直接看最后一行定位到出错位置
贴一下代码吧
self.theWebView.frame = CGRectMake(0, 50, WIDTH1, [UIScreen mainScreen].bounds.size.height - 100); NSString * htmlStr = nil; NSData *data=[NSData dataWithContentsOfFile:self.page.pageUrl options:0 error:NULL]; // NSString *result = [[[NSString alloc] initWithData:[data base64EncodedDataWithOptions:0] encoding:NSUTF8StringEncoding] autorelease]; NSString *result=[GTMBase64 stringByEncodingData:data]; htmlStr = [AESCrypt decrypt:result password:@"0123456789ABCDEF"];// if (self.readingBook.bookId == 0)// {// htmlStr = [[IYCCommon decodeBase64forFile:self.page.pageUrl] retain];// }// else// {// IYCSecurityManager *manager = [[IYCSecurityManager alloc] init];// htmlStr = [[manager decryptWithFilePath:self.page.pageUrl] retain];// [manager release];// } self.theWebView.dataDetectorTypes = UIDataDetectorTypeNone; [self.theWebView loadHTMLString:htmlStr baseURL:[NSURL fileURLWithPath:self.page.baseURL isDirectory:YES]]; [htmlStr release];// [data release];// [result release]; [self.view addSubview:self.theWebView];
到这里基本上可以看出问题了,就是 htnlStr release两次导致的
备注:一直以为是GTMBase64出问题了,花了太多时间在GTMbase64上
备注2:顺便记录一下,AES加密采用AESCrypt,在解密部分要注意解码编码方式
+ (NSString *)decrypt:(NSString *)base64EncodedString password:(NSString *)password{ NSData *encryptedData = [NSData base64DataFromString:base64EncodedString]; NSData *decryptedData = [encryptedData AES128DecryptedDataWithKey:password]; NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); return [[NSString alloc] initWithData:decryptedData encoding:enc];}
0 0
- iOS开发 message sent to deallocated instance问题解决
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- message sent to deallocated instance
- [**ViewController respondsToSelector:]: message sent to deallocated instance崩溃问题解决方法
- ios [UIImage class]: message sent to deallocated instance
- ios -[MTMeViewController scrollViewDidScroll:]: message sent to deallocated instance 0x7fc0f6f2
- iOS [MTMeViewController scrollViewDidScroll:]: message sent to deallocated instance
- ios message sent to deallocated instance 重复release 内存问题
- 启动Tensorboard
- React Native 之搭建开发环境(MacOS用户)
- fir.im Weekly
- 前言
- 树状数组——BZOJ3192/Luogu3253 [JLOI2013]删除物品
- iOS开发 message sent to deallocated instance问题解决
- CentOS6 安装golang
- 排序算法的稳定性与不稳定性
- 数据结构(三):线性表的链式存储结构
- OKHttp使用之粗陋封装
- GCD的基本概念和使用
- 消息队列设计
- java文件普通复制和NIO复制
- MATLAB中ismember函数