Saturday, August 8, 2020

#1 2020-06-05 10:33:56 am

mcsprodart
Member
Registered: 2013-03-09
Posts: 11

NSUserDefaults's / Bundle ID

Is there a way to force a script bundle name to a name other then the script bundle name?

I tried this:

Applescript:


set theID to "com.mycompanyname.TestName"
set theDefaults to current application's NSUserDefaults's alloc()'s initWithSuiteName:theID

It does not work, I get error:

Using your own bundle identifier as an NSUserDefaults suite name does not make sense and will not work. Break on _NSUserDefaults_Log_Nonsensical_Suites to find this


Filed under: initWithSuiteName

Offline

 

#2 2020-06-05 02:32:27 pm

mcsprodart
Member
Registered: 2013-03-09
Posts: 11

Re: NSUserDefaults's / Bundle ID

Found the answer. Posting for anyone else with this question......

Applescript:


set plistPath to "somepath:some.plist" --- point to any plist file
set theData to current application's NSData's dataWithContentsOfFile:(POSIX path of plistPath)
set infoDict to current application's NSPropertyListSerialization's propertyListWithData:theData options:0 format:(missing value) |error|:(missing value)
set theID to infoDict's objectForKey:"CFBundleIdentifier"
set theDefaults to current application's NSUserDefaults's alloc()'s initWithSuiteName:theID

Last edited by mcsprodart (2020-06-05 02:35:23 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)