• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
iTune Plist changes from NSUserdefaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iTune Plist changes from NSUserdefaults


  • Subject: iTune Plist changes from NSUserdefaults
  • From: Madhavi Gundeti <email@hidden>
  • Date: Wed, 11 Dec 2013 18:15:43 +0530

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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: iTune Plist changes from NSUserdefaults
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Question about adding NSTextView into a zoomed parent view (10.9)
  • Next by Date: Re: HTML emails from Objective C
  • Previous by thread: Question about adding NSTextView into a zoomed parent view (10.9)
  • Next by thread: Re: iTune Plist changes from NSUserdefaults
  • Index(es):
    • Date
    • Thread