非常奇怪的Objective C错误

问题描述

| 我会说我非常了解ObjectiveC。但是我刚刚找到了一个非常奇怪的错误。 我在一个类中有一个\“ int模式; \”成员变量。只需在init方法中写入\“ mode; \”即可更改类的行为(稍后不会取消分配) 即使编译器向我发出警告“声明无效” 到底是怎么回事 ? 我不能确定何时取消分配对象? 这是我的代码更详细:
@interface HelpScene : CCScene {
    int mode;
}
并在实施中
- (id) init {
    if (self=[super init]) {
        [[SomeObject alloc] initWithBlock:^(id sender) {
            mode;  // CHANGES BEHAVIoUR
            [Call CCDirector.replaceScene which usually ends up dealLocing self
            (the current scene). But not with the prevIoUs line anymore]
        }
    }
    return self;
}
    

解决方法

mode
的引用是
self->mode
的简写,这促使该块保留类实例。