macdriver icon indicating copy to clipboard operation
macdriver copied to clipboard

SetDefaultApplicationAtURLToOpenContentTypeCompletionHandler error

Open taramk opened this issue 1 year ago • 0 comments

error reported:

I'm noticing that this particular method:

  • (void)setDefaultApplicationAtURL:(NSURL *)applicationURL toOpenContentTypeOfFileAtURL:(NSURL *)url completionHandler:(void (^_Nullable)(NSError *_Nullable error))completionHandler API_AVAILABLE(macos(12.0));

has a nullable pointer to error for the error argument in the completion handler.

But in macdriver the callback accepts a non-pointer.

i've switched to a more reliable approach of using SetDefaultApplicationAtURLToOpenContentTypeCompletionHandler which lets me just look up the uniform type based on the extension rather than dealing with any files, and I get this error: Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be opened." UserInfo={NSUnderlyingError=0x600000c01050 {Error Domain=NSOSStatusErrorDomain Code=-50 "paramErr: error in user parameter list"}}

Fix according to @progrium :

we need to override that method with one that takes a callback that is nullable.

taramk avatar Sep 27 '23 17:09 taramk