Programmatic Equivalent of “defaults write” command, e.g., how to use NSUserDefaults?

后端 未结 2 1340
长情又很酷
长情又很酷 2021-01-06 09:21

Trying programmatically do what the \'defaults write\' command does in OS X. I can\'t seem to figure out how to get the correct preferences dictionary for the domain I\'m l

2条回答
  •  时光取名叫无心
    2021-01-06 09:56

    It might be easier to use Core Foundation for this, e.g.,

    CFPreferencesSetAppValue( CFSTR("mcx-expose-disabled"), kCFBooleanTrue, CFSTR("com.apple.dock") );
    CFPreferencesAppSynchronize( CFSTR("com.apple.dock") );
    

提交回复
热议问题