



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
【移动应用开发技术】iOS中多线程的经典崩溃示例
0x0Block回调的崩溃
__block
ViewController
*weakSelf
=
self;
[self.imageView
imageWithUrl:@""
completedBlock:^(UIImage
*image,
NSError
*error)
{
NSLog(@"%@",weakSelf.imageView.description);
}];0x1多线程下Setter的崩溃-
(void)setImageView:(UIImageView
*)imageView
{
if
(![_imageView
isEqual:imageView])
{
[_imageView
release];
_imageView
=
[imageView
retain];
}
}0x2更多Setter类型的崩溃@interface
ViewController
()
@property
(strong,nonatomic)
NSMutableArray
*array;
@endfor
(int
i
=
0;
i
<
100;
i++)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0),
^{
self.array
=
[[NSMutableArray
alloc]
init];
});
}/upload/information/20200623/126/120389.pngif(handler
==
nil)
{
hander
=
[[Handler
alloc]
init];
}
return
handler;Exception
Type:
SIGSEGV
Exception
Codes:
SEGV_ACCERR
at
0x12345678
Triggered
by
Thread:
1
@synchronized(self){
if(handler
==
nil)
{
hander
=
[[Handler
alloc]
init];
}
}
return
handler;0x3多线程下对变量的存取if
(self.xxx)
{
[self.dict
setObject:@"ah"
forKey:self.xxx];
}__strong
id
val
=
self.xxx;
if
(val)
{
[self.dict
setObject:@"ah"
forKey:val];
}0x4dispatch_group的崩溃dispatch_group_t
serviceGroup
=
dispatch_group_create();
dispatch_group_notify(serviceGroup,
dispatch_get_main_queue(),
^{
NSLog(@"Finish
downloading
:%@",
downloadUrls);
});
//
t
是一个包含一堆字符串的数组
[downloadUrls
enumerateObjectsUsingBlock:^(id
_Nonnull
obj,
NSUInteger
idx,
BOOL
*
_Nonnull
stop)
{
dispatch_group_enter(serviceGroup);
SDWebImageCompletionWithFinishedBlock
completion
=
^(UIImage
*image,
NSError
*error,
SDImageCacheType
cacheType,
BOOL
finished,
NSURL
*imageURL)
{
dispatch_group_leave(serviceGroup);
NSLog(@"idx:%zd",idx);
};
[[SDWebImageManager
sharedManager]
downloadImageWithURL:[NSURL
URLWithString:
downloadUrls[idx]]
options:SDWebImageLowPriority
progress:nil
completed:completion];
}];dispatch_barrier_sync(self.barrierQueue,
^{
SDWebImageDownloaderOperation
*operation
=
self.URLOperations[url];
if
(!operation)
{
operation
=
createCallback();
//
****注意这行****
self.URLOperations[url]
=
operation;
__weak
SDWebImageDownloaderOperation
*woperation
=
operation;
pletionBlock
=
^{
SDWebImageDownloaderOperation
*soperation
=
woperation;
if
(!soperation)
return;
if
(self.URLOperations[url]
==
soperation)
{
[self.URLOperations
removeObjectForKey:url];
};
};
}
//
****注意这行****
id
downloadOperationCancelToken
=
[operation
addHandlersForProgress:progressBlock
completed:completedBlock];
}0x5最后一个持有者释放后的崩溃-
(void)finishEditing
{
[Manager
removeObject:self];
[self
doSomething];
}Thread
0
Crashed:
0
libobjc.A.dylib
0x00000001816ec160
_objc_release
:16
(in
libobjc.A.dylib)
1
libobjc.A.dylib
0x00000001816edae8
__ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv
:508
(in
libobjc.A.dylib)
2
CoreFoundation
0x0000000181f4c9fc
__CFAutoreleasePoolPop
:28
(in
CoreFoundation)
3
CoreFoundation
0x0000000182022bc0
___CFRunLoopRun
:1636
(in
CoreFoundation)
4
CoreFoundation
0x0000000181f4cc50
_CFRunLoopRunSpecific
:384
(in
CoreFoundation)
5
GraphicsServices
0x0000000183834088
_GSEventRunModal
:180
(in
GraphicsServices)
6
UIKit
0x0000000187236088
_UIApplicationMain
:204
(in
UIKit)
7
Tmall4iPhone
0x00000001000b7ae4
main
main.m:50
(in
Tmall4iPhone)
8
libdyld.dylib
0x0000000181aea8b8
_start
:4
(in
libdyld.dylib)0x6对象的释放线程要和它处理事情的线程一致0x7performSelector:w
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 标准合同-室外景观工程施工合同
- 高三年级上册9月月考语文试卷汇编:文学类文本阅读
- 餐饮部工作计划表
- 消化内科诊疗规范与临床实践
- 心内科诊疗知识体系
- 老年人日常生活护理
- 医院保洁培训课件
- 护士主班工作流程
- 学校炊事员食品安全培训
- 整流模块培训课件
- ZZ022酒店服务赛项规程
- 通站(2017)8012 铁路站场排水构筑物
- 2024-2030年中国小型涡喷发动机行业竞争格局展望及投资策略分析报告
- UL2251标准中文版-2017电动汽车的插头插座和耦合器UL中文版标准
- 网络安全策略优化方案
- 工程建筑劳务合作协议范本
- 房屋优先购买权申请书
- 串标举报信范文
- 留学销售话术培训
- 35kV电力线路迁改专项施工方案
- 110kV变电站施工组织总设计
评论
0/150
提交评论