MacOs sandbox, security scoped bookmarks

  • Hi,

    I struggle writing a code related to MacOs security scoped bookmarks (related to MacOs sandboxing, where to keep access to user selected files across App runs one have to facilitate Security Scoped Bookmarks). Anyone having an experience on that matter or point to some links with examples?

    Env: Qt 5.10, MacOs High Sierra


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Try something like:

    QUrl url("file:///Users/your_user/your_file.extension");
    NSURL *nsUrl = url.toNSURL();
    NSError *error = nil;
    NSData *bookmark = [nsUrl bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope
    qDebug() << "Error" << error;
    qDebug() << QByteArray::fromNSData(bookmark);

    Hope it helps

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.