According to the MonoMac documentation the signature for NSWorkspace.RecycleUrls is:
[MonoMac.Foundation.Export("recycleURLs:completionHandler:")]
public virtual void RecycleUrls (MonoMac.Foundation.NSDictionary urls, NSWorkspaceUrlHandler completionHandler)
According to Apple’s documentation for NSWorkspace the signature for recycleURLs:completionHandler is:
- (void)recycleURLs:(NSArray *)URLs completionHandler:(void (^)(NSDictionary *newURLs, NSError *error))handler
I have an array of URLs that I want recycled.
Here I’m stumped – the Apple documentation says the first parameter is an NSArray but MonoMac wants an NSDictionary. All the functions to construct an NSDictionary want keys and values (unsurprisingly) whereas I only have values.
Is there anything to be done other than taking MonoMac’s implementation of RecycleUrls (reproduced below) and rewriting it to use an 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();
}
Mono’s binding was incorrect, I changed both
NSWorkspace.RecycleUrls()andNSWorkspace.DuplicateUrls()to take anNSArrayinstead ofNSDictionary, monomac commit b1eda57.This is the generated code:
Quick test: