简体   繁体   中英

How to copy a font programmatically to /System/Library/Fonts/?

I want to copy a font programmatically to the location /System/Library/Fonts/. I used the following coding to do this

NSFileManager *fileManager=[NSFileManager defaultManager];
[fileManager copyItemAtPath:sourcePath toPath:@/System/Library/Fonts error:&error];

For this I am getting the error..

Error Domain=NSPOSIXErrorDomain Code=13 UserInfo=0x4193e0 "The operation couldn’t be completed. Permission denied"   

If I copy the font manually it ask the password first and then it copies to the location. But If I done this programmatically means it is not asking for the password. How can I Implement this feature?

You will need to gain authorization to do a privileged operations from within your code.

The developer guide is available here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM