• 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
Re: plist issues driving me crazy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plist issues driving me crazy


  • Subject: Re: plist issues driving me crazy
  • From: Stéphane Sudre <email@hidden>
  • Date: Sun, 11 Jul 2004 00:50:53 +0200

On samedi, juillet 10, 2004, at 11:36 PM, Kodex wrote:

Ive been toying around with this for days and i still
cant get it working. Ive tried a number of sample code
and it compiles fine and dosnt give me any errors when
i run it but it dosnt do anything. Here is what i am
trying to do..

From within my application i need to load in
com.apple.desktop.plist and edit the field inside of
Root/Background/**A RANDOM NUMBER**/ImageFIlePath
my bigger problem is i cant seem to get a code sample
to edit anything much less the field i want to use,
the second problem i see comming will be editing a
field within a random number directory. Anyone have
any infomation on how to get this working right? Im
getting ready to start tearing my hair out. Thanks as
always in advance!

* A RANDOM NUMBER is just the Screen ID

* Some sample code

------------8<------------8<------------8<---------------

- (IBAction)doSomething:(id)sender
{
NSData * tData;
NSMutableDictionary * tDictionary=nil;

// The code to get the path is lame...

tData=[NSData dataWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences/ com.apple.desktop.plist"]];

// Little tip to get a complete mutable dictionary from a file

if (tData!=nil)
{
NSString * errorString;
NSPropertyListFormat format;

tDictionary=(NSDictionary *) [NSPropertyListSerialization propertyListFromData:tData
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&format
errorDescription:&errorString];

if (tDictionary==nil)
{
[errorString release];

return;
}
}
else
{
return;
}

if (tDictionary!=nil)
{
NSMutableDictionary * tBackgroundDictionary;


tBackgroundDictionary=[tDictionary objectForKey:@"Background"];

if (tBackgroundDictionary!=nil)
{
NSArray * tScreens;


tScreens=[NSScreen screens];

if (tScreens!=nil)
{
NSEnumerator * tScreenEnumerator;
NSScreen * tScreen;

tScreenEnumerator=[tScreens objectEnumerator];

while (tScreen=[tScreenEnumerator nextObject])
{
NSDictionary * tScreenInformation;

tScreenInformation=[tScreen deviceDescription];

if (tScreenInformation!=nil)
{
NSNumber * tNumber;

tNumber=[tScreenInformation objectForKey:@"NSScreenNumber"];

if (tNumber!=nil)
{
NSMutableDictionary * tBackgroundInformationForScreen;

tBackgroundInformationForScreen=[tBackgroundDictionary objectForKey:[tNumber stringValue]];

// Now if you really want to, you can modify the ImageFilePath value here

// To be completed

//[tBackgroundInformationForScreen setObject:@"YOUR_PATH" forKey:@"ImageFilePath"];

// Don't forget to modify the ImageFileAlias object too

// I think the BDAlias class can be useful here to get a NSData from a AliasHandle of the filePath
}
}
}
}
}
}
}

------------8<------------8<------------8<---------------

--
The Hairdresser
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >plist issues driving me crazy (From: Kodex <email@hidden>)

  • Prev by Date: Re: NSThread sleepUntilDate /CORRECTION
  • Next by Date: Re: plist issues driving me crazy
  • Previous by thread: plist issues driving me crazy
  • Next by thread: Re: plist issues driving me crazy
  • Index(es):
    • Date
    • Thread