- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
谁能告诉我以下我从 iOS 5 Developer's Cookbook 改编的代码有什么问题
- (void) startMonitoringUbiquitousDocumentsFolder
{
// Remove any existing query – stored in local instance variable
if (alertQuery) [alertQuery stopQuery];
// Search for all file names
alertQuery.predicate = [NSPredicate predicateWithFormat: @"NSMetadataItemFSNameKey == '*'"];
alertQuery.searchScopes = [NSArray arrayWithObject:
NSMetadataQueryUbiquitousDocumentsScope];
// Subscribe to query updates
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(alertUserToUpdates:)
name:NSMetadataQueryDidUpdateNotification
object:nil];
[alertQuery startQuery];
}
- (void) alertUserToUpdates
{
NSLog(@"Contents changed in ubiquitous documents folder");
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Home Monitor"
message:@"Something's going on."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:@"Check Recording", nil];
[alertView show];
[self stopMonitoringUbiquitousDocumentsFolder];
}
我收到一个异常,提示选择器 alertUserToUpdates: 无法识别。为什么它不能识别明明就在它旁边的方法?
2013-04-29 18:07:22.458 eyeFun[8231:907] -[RGPViewController alertUserToUpdates:]: unrecognized selector sent to instance 0x1fd506a0
2013-04-29 18:07:22.462 eyeFun[8231:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RGPViewController alertUserToUpdates:]: unrecognized selector sent to instance 0x1fd506a0'
*** First throw call stack:
(0x337eb3e7 0x3b4e6963 0x337eef31 0x337ed64d 0x33745208 0x3373c349 0x34053b7f 0x340ab327 0x3373c349 0x337b810f 0x37880de9 0x340fa657 0x337c0857 0x337c0503 0x337bf177 0x3373223d 0x337320c9 0x3731133b 0x3564e2b9 0x465b5 0x3b913b20)
libc++abi.dylib: terminate called throwing an exception
最佳答案
因为它不就在它旁边。
您告诉它使用名为 alertUserToUpdates:
的选择器。您有一个名为 alertUserToUpdates
的方法。 :
很重要——它表示该方法采用一个参数,但实际方法不采用参数。
您的方法应该采用类型为 NSNotification
的参数。
关于ios - NSMetadataQueryDidUpdateNotification 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16305182/
谁能告诉我以下我从 iOS 5 Developer's Cookbook 改编的代码有什么问题 - (void) startMonitoringUbiquitousDocumentsFolder {
为了监控我的iCloud容器中的文件变化,我注册了 [[NSNotificationCenter defaultCenter] addObserver:self
我正在尝试在 OS X 应用程序上启动并运行 NSMetadataQueryDidUpdateNotification,以便在 iCloud 无处不在容器中的文件更新时提醒我。我一直在做很多研究(包括
在尝试解决这个问题时,我已经很头疼了:在我当前的应用程序中,我使用 iCloud 来存储我的文档 - 但我不能使用基于 UIDocument 的数据存储。所以我的方法是遵循 WWDC 2012 文章
我是一名优秀的程序员,十分优秀!