Mac OS 开发 为什么这样写不行

"NSTask *capture = [[NSTask alloc] init];

capture.launchPath = @"/usr/sbin/screencapture";

capture.arguments = [NSArray arrayWithObjects:@"-i",@"-c", nil];

[capture setTerminationHandler: ^(NSTask *t) {

NSPasteboard *pboard = [NSPasteboard generalPasteboard];

if ([pboard pasteboardItems].count <= 0) return ;

NSPasteboardItem *pboardItem = [[pboard pasteboardItems] objectAtIndex:0];

NSString *pboardItemType = [[pboard types] objectAtIndex:0];

NSData *imageData = [pboardItem dataForType:pboardItemType];

NSImage *image = [[NSImage alloc] initWithData:imageData];

__weak __typeof(self) weakself= self;

dispatch_async(dispatch_queue_create(0, 0), ^{

dispatch_async(dispatch_get_main_queue(), ^{

weakself.iconView.image = image;

});

});

}];

[capture launch]; "

这样写报错 screencapture: cannot run two interactive screen captures at a time

  回复

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。