MacOs sandbox, security scoped bookmarks
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
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 includingResourceValuesForKeys:nil relativeToURL:nil error:&error]; qDebug() << "Error" << error; qDebug() << QByteArray::fromNSData(bookmark);
Hope it helps