I have a strange error when resolving a security-scoped bookmark (SSB) in my 
screensaver.
The code works fine for almost all users (even under Mojave), except for one 
user under Mojave (10.14.6).


Here is the code in question:

        NSError * error;
        BOOL isStale = NO;
        NSURL * dir_location = [NSURL URLByResolvingBookmarkData: bookmark
                                                       options: 
NSURLBookmarkResolutionWithSecurityScope
                                                 relativeToURL: nil
                                           bookmarkDataIsStale: & isStale
                                                         error: & error];

The method returns NULL, and error says:

  Error Domain=NSCocoaErrorDomain Code=259 "The file couldn't be opened because 
it isn't in the correct format."

The SSB points to a directory in the user's home.
I can see that in the log, because in my code I do

            NSDictionary * dict = [NSURL resourceValuesForKeys: [NSArray 
arrayWithObjects: NSURLPathKey, nil]
                                              fromBookmarkData: bookmark ];

and then I output  [dict objectForKey: NSURLPathKey] .

The user has opened the directory in the previous run, and I am creating and 
storing an SSB with this code:

        NSError * systemError;
        NSData * dir_bookmark = [dir bookmarkDataWithOptions: 
NSURLBookmarkCreationWithSecurityScope
                               includingResourceValuesForKeys: nil
                                                relativeToURL: nil
                                                        error: &systemError];

and it seems to work just fine.


I don't know whether or not it matters: the error occurs in a screensaver of 
mine,
i.e., it occurs when the users launches the screensaver moving the mouse into 
the respective hot corner.
But the SSB is created and resolved by exactly the same .saver executable.


Does anyone have an idea why -URLByResolvingBookmarkData  might fail?
Or could some kind soul give me hints how I might be able to track down the bug?
(Of course, I tried top google, to no avail.)


I am at a loss here ...
Thanks a lot in advance.
Best regards, Gabriel


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to