循环,使我得到这个,用于在功能循环,但它永远不会进入,对于没有得到进入
for (Window *window in _app.windows) {
NSLog(@"test.");
}
我是初学者所以我在哪里开始调试这个,看看它出错了?
EDIT 这是另一个类
(其在一个函数(loadApp),我打电话在我的ViewController,像这样:self.app = [MyClass的loadApp],上面的代码还在
Window *window = [[Window alloc] initWithName:title subtitle:subtitle number:number ident:ident type:type chapternumber:chapternumber icon:icon text:text img:img question:question answerFormat:answerFormat answerLength:answerLength tip1:tip1 tip2:tip2 tip3:tip3 tip1Answer:tip1Answer tip2Answer:tip2Answer tip3Answer:tip3Answer];
[app.windows addObject:window];
}
return app;
您正试图对数组执行快速枚举。如果你的表达式'_app.windows'是零或者是空的,你将永远不会进入循环。 – trudyscousin 2013-02-26 17:54:10
我做了一个简单的if(_app == nil),它不是零 – user1345821 2013-02-26 17:56:30
然后'windows'必须是空的,即不包含任何元素。 – trudyscousin 2013-02-26 17:57:04