这是我的功能:
- (void) function{
if (_app.error == nil) {
for (Window *window in _app.windows) {
NSLog(@"test.");
}
}
else {
NSLog(@"%@",[_app.error localizedDescription]);
}
}
而不是进入 for 循环并打印出“test.”,而是从 else 语句中给我“(null)”。我究竟做错了什么?
+ (App *)loadApp {
NSString *filePath = [self dataFilePath:FALSE];
NSData *xmlData = [[NSMutableData alloc] initWithContentsOfFile:filePath];
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData options:0 error:&error];
App *app = [[App alloc] init];
if (doc == nil) app.error = error;
...etc