Hi all, I have created Following code to set my screen saver as default screen saver on MAC 10.6 (Snow Leopard). This code is working fine on our systems but when we distribute in installer then it does not set screen saver as default. Is it user permissions issue or some code problem ?the user login currently i am using is admin.
NSString *path = @"~/Library/Preferences/ByHost/com.apple.screensaver.";
OSStatus err;
UInt32 numEnetEntries = kMaxEnetEntries;
char enetstr[32];
EnetData gedata[kMaxEnetEntries];
err = GetEthernetAddressInfo((EnetData*)&gedata, &numEnetEntries);
if(err == noErr && numEnetEntries > 0)
{
MACAddress *eaddr = (MACAddress*)gedata[0].macAddress;
EnetAddrToString(eaddr, enetstr);
NSString *macAdd = [NSString stringWithCString:enetstr];
macAdd = [[macAdd stringByReplacingOccurrencesOfString:@":" withString:@""] lowercaseString];
path = [[path stringByAppendingFormat:@"%@.plist", macAdd] stringByStandardizingPath];
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
NSMutableDictionary *moduleDict = [plistDict objectForKey:@"moduleDict"];
[moduleDict setValue:@"MyScreenSaver" forKey:@"moduleName"];
[moduleDict setValue:@"/Library/Screen Savers/MyScreenSaver.saver" forKey:@"path"];
NSNumber *yourNumber = [NSNumber numberWithInt:interval];
[plistDict setValue:yourNumber forKey:@"idleTime"];
[plistDict writeToFile:path atomically:YES];
}
Thanks