progrium / darwinkit

Native Mac APIs for Go. Previously known as MacDriver
MIT License
4.42k stars 147 forks source link

SetDefaultApplicationAtURLToOpenContentTypeCompletionHandler error #220

Open taramk opened 9 months ago

taramk commented 9 months ago

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.