Hi,

I am developing one MAC application to change iTunes Parental control
setting programmatically.

I am using NSUserdefaults class to achieve above. Please find the sample
code.

#define kBundleIdentifier @"com.apple.iTunes"


    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];



    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];



    NSDictionary *defaultPreferences1 = [defaults persistentDomainForName:
kBundleIdentifier];

    [defaults synchronize];


    NSMutableDictionary *mprefs = [defaultPreferences1 mutableCopy];




    [mprefs setValue:@"YES" forKey:@"restrictExplicit"];

    [mprefs setValue:@"YES" forKey:@"restrictMovies"];

    [mprefs setValue:@"200" forKey:@"moviesLimit"];

    [mprefs setValue:@"YES" forKey:@"restrictTVShows"];

    [mprefs setValue:@"400" forKey:@"tvShowsLimit"];

    [mprefs setValue:@"YES" forKey:@"restrictGames"];

    [mprefs setValue:@"200" forKey:@"gamesLimit"];


    [defaults removePersistentDomainForName:kBundleIdentifier];

    [defaults synchronize];



    //Adding modified Prefs

    [defaults setPersistentDomain:mprefs forName:kBundleIdentifier];

    [defaults synchronize];


I have a daemon running as root user.But root user unable to set the iTunes
preferences.

When I run the above code as login user then the iTune parent control
settings got changed.

Please let me know what I am missing here. Why I am not able to change
these settings as root user.

I tried one more method also:

 NSString *usrPlistPath =
@"/Users/madhavi/Library/Preferences/com.apple.iTunes.plist";

    NSLog(@"Madhavi usrPlistPath is %@", usrPlistPath);




    NSDictionary *defaultPreferences = [NSDictionary
dictionaryWithContentsOfFile:usrPlistPath];

    [defaults registerDefaults:defaultPreferences];

    [defaults synchronize];



    [defaults  setBool:YES forKey:@"restrictExplicit"];

    [defaults  setBool:YES forKey:@"restrictMovies"];

    [defaults  setBool:YES forKey:@"restrictTVShows"];

    [defaults  setBool:YES forKey:@"restrictGames"];



    [defaults  setInteger:200 forKey:@"moviesLimit"];

    [defaults  setInteger:400 forKey:@"tvShowsLimit"];

    [defaults  setInteger:200 forKey:@"gamesLimit"];



    [defaults synchronize];



With the above code I am able to create Userdefaults as root user, but
these values are not reflecting in plist. so that iTune preferences also
not getting changed.


It would be helpful to me if you provide any clue on above.


How to change iTunes plist using NSUserdefaults as root user.(Because I
don't want to change plist file directly)


Please suggest me on this.



Thanks and Regards,
Madhavi G.
_______________________________________________

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