Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone N错误、自动释放和块_Iphone_Ios_Objective C_Ipad - Fatal编程技术网

Iphone N错误、自动释放和块

Iphone N错误、自动释放和块,iphone,ios,objective-c,ipad,Iphone,Ios,Objective C,Ipad,我有以下代码: __autoreleasing NSError *error = nil; __block BOOL isPaidFeed = NO; [[MyManager sharedInstance].tempAddedFeeds enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [[MyManager sharedInstance] addSource:obj toPag

我有以下代码:

__autoreleasing NSError *error = nil;
    __block BOOL isPaidFeed = NO;

    [[MyManager sharedInstance].tempAddedFeeds enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [[MyManager sharedInstance] addSource:obj toPage:pageTitle error:&error];
        if(error){
            *stop = YES;
        }

    }];

但是,它给了我一个错误,我在块中使用了_自动删除。如何解决此问题?不使用枚举数?

尝试将错误声明移动到块内部。

如果您只是想确保块不保留对象,那么使用“弱”或“不安全”unretained如何。在这种情况下,我会将其保持为强。它是一个基础类,而不是使用它的人通常会冒险保留一个循环。但是,如果您只是在某种方法中创建NSERROR对象,为什么要创建一个强引用。