Skip to content

Instantly share code, notes, and snippets.

@floehopper
Created September 25, 2009 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floehopper/193417 to your computer and use it in GitHub Desktop.
Save floehopper/193417 to your computer and use it in GitHub Desktop.
SecAccessRef createAccess(NSString *accessLabel)
{
OSStatus err;
SecAccessRef access=nil;
NSArray *trustedApplications=nil;
//Make an exception list of trusted applications; that is,
// applications that are allowed to access the item without
// requiring user confirmation:
SecTrustedApplicationRef myself, someOther;
//Create trusted application references; see SecTrustedApplications.h:
err = SecTrustedApplicationCreateFromPath(NULL, &myself);
err = SecTrustedApplicationCreateFromPath("/Applications/Mail.app",
&someOther);
trustedApplications = [NSArray arrayWithObjects:(id)myself,
(id)someOther, nil];
//Create an access object:
err = SecAccessCreate((CFStringRef)accessLabel,
(CFArrayRef)trustedApplications, &access);
if (err) return nil;
return access;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment