根据MonoMac 文档,签名为NSWorkspace.RecycleUrls
:
[MonoMac.Foundation.Export("recycleURLs:completionHandler:")]
public virtual void RecycleUrls (MonoMac.Foundation.NSDictionary urls, NSWorkspaceUrlHandler completionHandler)
根据Apple的NSWorkspace
签名文档recycleURLs:completionHandler
是:
- (void)recycleURLs:(NSArray *)URLs completionHandler:(void (^)(NSDictionary *newURLs, NSError *error))handler
我有一组要回收的 URL。
在这里我很难过 - Apple 文档说第一个参数是 anNSArray
但 MonoMac 想要一个NSDictionary
. 构造所需NSDictionary
键和值的所有功能(不出所料),而我只有values。
除了采用 MonoMac 的实现RecycleUrls
(在下面转载)并将其重写为使用NSArray
?
[Export("recycleURLs:completionHandler:")]
public unsafe virtual void RecycleUrls(NSDictionary urls, NSWorkspaceUrlHandler completionHandler)
{
if (urls == null)
{
throw new ArgumentNullException("urls");
}
if (completionHandler == null)
{
throw new ArgumentNullException("completionHandler");
}
BlockLiteral blockLiteral = default(BlockLiteral);
blockLiteral.SetupBlock(NSWorkspace.static_InnerNSWorkspaceUrlHandler, completionHandler);
if (this.IsDirectBinding)
{
Messaging.void_objc_msgSend_IntPtr_IntPtr(base.Handle, NSWorkspace.selRecycleURLsCompletionHandler_, urls.Handle, (IntPtr)((void*)(&blockLiteral)));
}
else
{
Messaging.void_objc_msgSendSuper_IntPtr_IntPtr(base.SuperHandle, NSWorkspace.selRecycleURLsCompletionHandler_, urls.Handle, (IntPtr)((void*)(&blockLiteral)));
}
blockLiteral.CleanupBlock();
}