objective-c -gdb remote返回错误:E08调用完成块时(EXC_BAD_ACCESS)

栏目: C · 发布时间: 5年前

内容简介:翻译自:https://stackoverflow.com/questions/12809343/gdb-remote-returned-an-error-e08-when-calling-completion-block-exc-bad-access

我正在使用ARC,而在iOS6上我有些奇怪的崩溃:

gdb remote返回错误:E08

在堆栈跟踪中,之前的方法位于调用完成块的行上.我阅读了很多关于块和ARC的内容,但是在使用它们时,我仍然没有信心:

(简化方法并遗漏了一些代码)

- (void) method1: (void(^)(NSMutableArray *a)) completionBlock withFailedBlock:(void(^)(NSInteger errorCode,NSString *error)) failedBlock {
    __weak Controller *weakSelf = self;

    ...

    if(condition)
        completionBlock(weakSelf.a);

    //still do method2, since we might get updated data
    [weakself.service method2:^(NSMutableArray *a2) {
        weakSelf.shouldRefresh = NO;

        ...
        completionBlock(a2); //<-- sometimes crashes here
    } withFailedBlock:^(NSInteger errorCode, NSString *error) {
        failedBlock(errorCode, error);
    }];


} withFailedBlock:^(NSInteger errorCode, NSString *error) {
    failedBlock(errorCode, error);
}];

调用代码:

[[Controller sharedController] method1:^(NSMutableArray *a) {
    //save result in model (singleton)
    [Model sharedModel].a = a;
    [weakSelf refreshUI];

} withFailedBlock:^(NSInteger errorCode,NSString *error) {
    ;//show alert

}];

当我检查它周围的块和值时,它们似乎没问题.我也有NSZombie.

我的completionBlock应该被自动复制,因为它是从块中引用的.

我在这里想念的是什么?

我也看过iOS5和4.3上的崩溃,但从来没有gdb远程返回错误:E08.调试器中的信息在这些情况下也没有帮助.我正在使用 PLWeakCompatibility ,以便我可以在iOS4.3下支持__weak

你还有这个问题吗?

在这种情况下,为什么你需要weakSelf.在这种情况下,你看起来并不像是在捕捉自我.你把它留下来时代码是否仍会崩溃?

顺便说一句,我认为当你试图为你的问题简化它时,你的method1实现有点乱.

- (void) method1: (void(^)(NSMutableArray *a)) completionBlock withFailedBlock:(void(^)(NSInteger errorCode,NSString *error)) failedBlock {
    ...
} withFailedBlock:^(NSInteger errorCode, NSString *error) {
    ...
}];

看起来不像是一个有效的方法实现.不应该是这样的:

- (void) method1: (void(^)(NSMutableArray *a)) completionBlock withFailedBlock:(void(^)(NSInteger errorCode,NSString *error)) failedBlock {
    ...
}

翻译自:https://stackoverflow.com/questions/12809343/gdb-remote-returned-an-error-e08-when-calling-completion-block-exc-bad-access


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

RESTful Web Services Cookbook中文版

RESTful Web Services Cookbook中文版

Subbu Allamaraju / 丁雪丰、常可 / 电子工业出版社 / 2011-9 / 59.00元

RESTful Web Services Cookbook中文版:REST最佳实践手册,ISBN:9787121143908,作者:(美)Subbu Allamaraju(沙布·阿拉马拉尤)著,丁雪丰,常可 译一起来看看 《RESTful Web Services Cookbook中文版》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具