【发布时间】:2011-07-28 07:43:20
【问题描述】:
当用户点击默认按钮时,我从下面的警报表代码中收到以下错误:
-[NSRectSet objectForKey:]:无法识别的选择器发送到实例 0x400876300
顺便说一句,代码在 Snow Leopard 中运行良好,但在 Lion 中出现了问题。
NSMutableDictionary * extrasDict = [[NSMutableDictionary alloc] init];
[extrasDict setObject:@"http://www.google.com" forKey:@"link"];
NSAlert * alert = [NSAlert alertWithMessageText:@"Published Successfully"
defaultButton:@"View Collage on Facebook"
alternateButton:nil
otherButton:@"Cancel"
informativeTextWithFormat:@"Successfully published to Facebook."];
[alert beginSheetModalForWindow:myWindow
modalDelegate:self
didEndSelector:@selector(publishedSuccessfullyDidEnd:returnCode:contextInfo:)
contextInfo:extrasDict];
- (void)publishedSuccessfullyDidEnd:(NSAlert *)alert
returnCode:(NSInteger)returnCode
contextInfo:(void *)contextInfo {
if (returnCode == NSAlertDefaultReturn) {
[[NSWorkspace sharedWorkspace] openURL:
[NSURL URLWithString:[(NSDictionary*)contextInfo objectForKey:@"link"]]];
}
}
【问题讨论】:
-
您的代码对我来说看起来不错。我看不出错误的根源是什么。它一定在别的地方。
-
顺便说一句,代码在 Snow Leopard 上运行良好,但在 Lion 中出现了问题。
-
如果您有 Xcode 4.1,请查看有关您正在使用的所有方法的文档。其中之一可能已经改变。抱歉,没有更好的计划。
标签: objective-c cocoa macos