当用户点击默认按钮时,我从下面的警报表代码中收到以下错误:
- [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"]]];
}
}
答案 0 :(得分:3)
如果您正在使用垃圾收集,请将extrasDict
存储在实例变量中 - 无论何处都无关紧要 - 因此它不会在运行循环结束时释放。你需要字典,直到didEndSelector
可以对它进行操作。
答案 1 :(得分:0)
我已经执行了你的编码部分。它运作良好。检查编码的剩余部分。