我试图从一个NSBundle中复制一个NSString到粘贴板上,这个plugin作为插件加载到另一个程序中。
由于某些原因,[NSPasteboard generalPasteboard]返回nil。
我的代码来自苹果的NSPasteboard documentation和NSPasteboard programming guide
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
// Outputs: (null)
NSLog(@"%@", pasteboard);
[pasteboard clearContents];
BOOL copiedToPasteboard = [pasteboard writeObjects:@[@"The string"]];有没有可能是我无意中做了什么导致这种情况的?
发布于 2012-09-28 07:02:19
我的问题已经通过重装我的操作系统解决了。
我只能假设某些东西,在某些地方,在某个时间被破坏,导致了这个令人气愤的问题。
发布于 2012-09-23 19:45:54
我构建了一个最小的应用程序,它加载了一个包,并在每个步骤中添加了[NSPasteboard generalPasteboard]返回值的日志记录。不幸的是,我无法重现这个问题。下面是我得到的输出:
NUAppDelegate> init:<NSPasteboard: 0x100647740>
NUAppDelegate> awakeFromNib:<NSPasteboard: 0x100647740>
NUAppDelegate> applicationDidFinishLaunching::<NSPasteboard: 0x100647740>
Loading plugin
Plugin> init:<NSPasteboard: 0x100647740>
Plugin> someMethod:<NSPasteboard: 0x100647740>没有更多的细节,我看不出我们怎么能找到答案。你有没有我们可以下载或检查的代码?
https://stackoverflow.com/questions/12491936
复制相似问题