iOS开发 message sent to deallocated instance问题解决
2017-04-19 14:48
585 查看
问题
直接看截图吧解决方法
1. 活动监视器查看APP 进程号PID
2. terminal里查看问题
使用命令 malloc_history PID address |grep addressPID用进程号代替,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]; }
相关文章推荐
- Xcode做ios开发时 message sent to deallocated instance问题的解决方法(gdb和lldb)
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
- ios message sent to deallocated instance 重复release 内存问题
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
- [CALayer release]: message sent to deallocated instance iOS内存过度释放问题
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- [CALayer release]: message sent to deallocated instance iOS内存过度释放问题
- [**ViewController respondsToSelector:]: message sent to deallocated instance崩溃问题解决方法
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- message sent to deallocated instance问题的解决方法(gdb和lldb)
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
- iOS [xxxxController respondsToSelector:]: message sent to deallocated instance 0x1310293e0崩溃问题
- iOS内存错误EXC_BAD_ACCESS的解决办法(message sent to deallocated instance)
- Message sent to deallocated instance 问题解决方法
- iOS内存错误EXC_BAD_ACCESS的解决方法(message sent to deallocated instance)
- [CFString release]: message sent to deallocated instance问题