【发布时间】:2012-03-26 17:25:56
【问题描述】:
我真的需要帮助。在这一点上我很绝望。
我有 NSOperation,当添加到 NSOperationQueue 时没有被触发。 我添加了一些日志来查看 NSOperation 状态,结果如下:
Queue operations count = 1
Queue isSuspended = 0
Operation isCancelled? = 0
Operation isConcurrent? = 0
Operation isFinished? = 0
Operation isExecuted? = 0
Operation isReady? = 1
Operation dependencies? = 0
代码很简单。没什么特别的。
LoadingConflictEvents_iPad *loadingEvents = [[LoadingConflictEvents_iPad alloc] initWithNibName:@"LoadingConflictEvents_iPad" bundle:[NSBundle mainBundle]];
loadingEvents.modalPresentationStyle = UIModalPresentationFormSheet;
loadingEvents.conflictOpDelegate = self;
[self presentModalViewController:loadingEvents animated:NO];
[loadingEvents release];
ConflictEventOperation *operation = [[ConflictEventOperation alloc] initWithParameters:wiLr.formNumber pWI_ID:wiLr.wi_id];
[queue addOperation:operation];
NSLog(@"Queue operations count = %d",[queue operationCount]);
NSLog(@"Queue isSuspended = %d",[queue isSuspended]);
NSLog(@"Operation isCancelled? = %d",[operation isCancelled]);
NSLog(@"Operation isConcurrent? = %d",[operation isConcurrent]);
NSLog(@"Operation isFinished? = %d",[operation isFinished]);
NSLog(@"Operation isExecuted? = %d",[operation isExecuting]);
NSLog(@"Operation isReady? = %d",[operation isReady]);
NSLog(@"Operation dependencies? = %d",[[operation dependencies] count]);
[operation release];
现在我的操作在 main 方法上做了很多事情,但问题从来没有被调用过。 main 永远不会被执行。 最奇怪的事情(相信我,我还没有疯……)。如果我在任何 NSLog 行或创建操作中放置一个断点,主方法将被调用,一切都会完美运行。
这已经运行了很长时间了。我最近一直在做一些改变,显然有些事情搞砸了。其中一项更改是将设备升级到 iOS 5.1 SDK (iPad)。
添加一些东西,我有这个应用程序的 iPhone (iOS 5.1) 版本,它使用相同的 NSOperation 对象。区别仅在于 UI,一切正常。
哦,这只会在实际设备上失败。在模拟器中一切正常。
任何帮助将不胜感激。
问候,
【问题讨论】:
标签: ios nsoperation nsoperationqueue