On Sep 10, 2014, at 9:39 PM, Graham Cox <graham....@bigpond.com> wrote:

> On 11 Sep 2014, at 12:14 pm, Charles Srstka <cocoa...@charlessoft.com> wrote:
> 
>> If that's true, then why does the 'defaults' program work for sandboxed 
>> apps, while NSUserDefaults does not?
> 
> 
> Where did you get the idea that NSUserDefaults doesn't work for sandboxed 
> apps? It certainly does.

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
        NSDictionary *domain = [def 
persistentDomainForName:@"com.apple.TextEdit"];
        
        NSLog(@"%@", domain);
    }
    return 0;
}

returns:

2014-09-10 22:17:12.713 test[94866:303] {
    NSNavLastRootDirectory = "~/Desktop";
    NSNavPanelExpandedSizeForOpenMode = "{767, 545}";
    NSNavPanelExpandedSizeForSaveMode = "{585, 448}";
    NSNavPanelExpandedStateForSaveMode = 1;
}
Program ended with exit code: 0

$ defaults read com.apple.TextEdit
{
    ABDirectoryResultColumnTitle = Phone;
    Encodings =     (
        10,
        4,
        30,
        5,
        12,
        2147486212,
        2147485224
    );
    IgnoreHTML = 1;
    NSColorPanelMode = 1;
    NSColorPanelVisibleSwatchRows = 1;
    NSColorPickerSlidersDefaults = 1;
    NSDocumentSuppressTempVersionStoreWarning = 0;
    NSFontPanelAttributes = "1, 0";
    NSFontPanelPreviewHeight = 0;
    NSNavBrowserPreferedColumnContentWidth = 186;
    NSNavLastRootDirectory = "~/Desktop";
    NSNavLastUserSetHideExtensionButtonState = 0;
    NSNavPanelExpandedSizeForOpenMode = "{585, 401}";
    NSNavPanelExpandedSizeForSaveMode = "{808, 458}";
    NSNavPanelExpandedStateForSaveMode = 1;
    NSNavSidebarWidth = 120;
    "NSTableView Columns NSNavOutlineColumnSearchSettings" =     (
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0b646973 706c6179 4e616d65 86>,
        306,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 076d6f64 44617465 86>,
        88,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c637265 6174696f 6e446174 6586>,
        95,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0e6c6173 744f7065 6e656444 
61746586>,
        95,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 136b696e 64576974 686f7574 
506c6174 666f726d 86>,
        62,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c73686f 72745665 7273696f 6e86>,
        62,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 096c6162 656c4e61 6d6586>,
        62,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c706879 73696361 6c53697a 6586>,
        60
    );
    "NSTableView Columns NSNavOutlineColumnSettings.v1" =     (
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0b646973 706c6179 4e616d65 86>,
        313,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 076d6f64 44617465 86>,
        88,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c637265 6174696f 6e446174 6586>,
        95,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0e6c6173 744f7065 6e656444 
61746586>,
        95,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 136b696e 64576974 686f7574 
506c6174 666f726d 86>,
        62,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c73686f 72745665 7273696f 6e86>,
        62,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 096c6162 656c4e61 6d6586>,
        62,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c706879 73696361 6c53697a 6586>,
        60
    );
    "NSTableView Hidden Columns NSNavOutlineColumnSearchSettings" =     (
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 076d6f64 44617465 86>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c637265 6174696f 6e446174 6586>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 136b696e 64576974 686f7574 
506c6174 666f726d 86>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c73686f 72745665 7273696f 6e86>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 096c6162 656c4e61 6d6586>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c706879 73696361 6c53697a 6586>
    );
    "NSTableView Hidden Columns NSNavOutlineColumnSettings.v1" =     (
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c637265 6174696f 6e446174 6586>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0e6c6173 744f7065 6e656444 
61746586>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 136b696e 64576974 686f7574 
506c6174 666f726d 86>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c73686f 72745665 7273696f 6e86>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 096c6162 656c4e61 6d6586>,
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0c706879 73696361 6c53697a 6586>
    );
    "NSTableView Sort Ordering NSNavOutlineColumnSearchSettings" =     (
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0b646973 706c6179 4e616d65 86>,
        1
    );
    "NSTableView Sort Ordering NSNavOutlineColumnSettings.v1" =     (
        <040b7374 7265616d 74797065 6481e803 84014084 8484084e 53537472 
696e6701 8484084e 534f626a 65637400 8584012b 0b646973 706c6179 4e616d65 86>,
        1
    );
    "NSToolbar Configuration com.apple.NSColorPanel" =     {
        "TB Is Shown" = 1;
    };
    "NSWindow Frame Address Book" = "302 693 480 253 0 0 1680 1028 ";
    "NSWindow Frame NSColorPanel" = "1002 313 214 309 0 0 1920 1178 ";
    "NSWindow Frame NSFindPanel" = "607 0 525 174 0 0 1440 878 ";
    "NSWindow Frame NSFontPanel" = "408 51 457 275 0 0 1440 878 ";
    "NSWindow Frame NSNavGotoPanel" = "654 960 432 134 0 0 1920 1178 ";
    "NSWindow Frame NSNavPanelAutosaveName" = "213 266 466 283 0 0 1440 878 ";
    "NSWindow Frame Text Encodings" = "736 292 338 426 0 0 1440 878 ";
    "NSWindow Frame com.apple.typography_panel_Handwriting-Dakota" = "340 537 
260 88 0 0 1440 878 ";
    "NSWindow Frame com.apple.typography_panel_TimesNewRomanPSMT" = "359 661 
260 42 0 0 1024 746 ";
    OCSHDontOpenUntitledFile = 0;
    OCSHTornOffMenuList =     {
        Format =         {
            position = "{744, 347}";
        };
        Help =         {
            position = "{685, 415}";
        };
    };
    PMPrintingExpandedStateForPrint = 1;
    PMPrintingExpandedStateForPrint2 = 1;
    PageNumberPosition = 3;
    PageNumberStart = 3;
    TimesNewRomanPSMT =     {
    };
    WebIconDatabaseDirectoryDefaultsKey = "~/Library/Icons";
    "dv  com.apple.soundmgr._DV Sound Output Settings" = <7d000000>;
}

Charles


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to