我正在通过以下代码从文件加载Quartz合成:
// quartz is a QCView in the XIB file
QCComposition *qc = [QCComposition compositionWithFile:@"res/wdq.qtz"];
//NSLog(@"input keys %@",[qc inputKeys]);
//NSLog(@"copyright %@",[[qc attributes] valueForKey:QCCompositionAttributeCopyrightKey]);
[quartz loadComposition:qc];
我收到错误:
*** <QCComposition = 0x100258d80 | identifier = "(null)" | source = (null) | backing = "res/wdq.qtz": Failed loading composition
(文件存在于位置,从IB加载文件在IB内部运行,但在运行应用程序时不运行)
Mac OS X Lion 10.7.3 | XCode 4.2 | Quartz Composer 4.5
答案 0 :(得分:0)
工作目录可能不是您认为的那样。尝试使用绝对路径引用它。
例如,假设qtz文件位于bundle的Resources文件夹中:
NSString *path = [[NSBundle mainBundle] pathForResource:@"wdq" ofType:@"qtz" inDirectory:@"res"]]l
QCComposition *qc = [QCComposition compositionWithFile:path];