当用户按下默认按钮时,我从下面的警报表代码中得到以下错误:
-NSRectSet objectForKey::未识别的选择器发送到实例0x400876300
顺便说一句,这段代码在雪豹中运行得很好,但是这个问题出现在狮子身上。
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"]]];
}
}发布于 2011-08-17 05:04:01
如果您使用的是垃圾收集,那么将extrasDict存储在实例变量中--在任何地方都没关系--所以它不会在run循环结束时释放。你需要查字典,直到didEndSelector能对它采取行动为止。
发布于 2011-07-30 04:27:07
我已经完成了你的编码部分。效果很好。检查编码的其余部分。
https://stackoverflow.com/questions/6855573
复制相似问题