Re: Confusion with app settings / NSUserDefaults

2023-08-16 Thread Saagar Jha via Cocoa-dev
Yes, although in practice I’ve seen the preferences make it to disk fairly quickly after app termination. Saagar Jha > On Aug 15, 2023, at 13:36, Gabriel Zachmann wrote: > > Ah, thanks a lot for the insights! > > Could it happen that the new settings have not been written to disk even if > t

Re: Confusion with app settings / NSUserDefaults

2023-08-15 Thread Gabriel Zachmann via Cocoa-dev
Right, that makes sense, in particular with Saga's insights in mind. > Use the commend “defaults delete de.zach.ArtSaverApp” to delete all your > prefs. That should remove them everywhere. > smime.p7s Description: S/MIME cryptographic signature __

Re: Confusion with app settings / NSUserDefaults

2023-08-15 Thread Gabriel Zachmann via Cocoa-dev
Ah, thanks a lot for the insights! Could it happen that the new settings have not been written to disk even if the app has quit normally? Or, in other words, there might be key/value pairs stored in cfprefsd's internal/runtime storage, even if i have changed the app and those key/value pairs do

Re: Confusion with app settings / NSUserDefaults

2023-08-06 Thread Marco S Hyman via Cocoa-dev
Use the commend “defaults delete de.zach.ArtSaverApp” to delete all your prefs. That should remove them everywhere. At least that is what as worked for my in my limited experience. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not

Re: Confusion with app settings / NSUserDefaults

2023-08-06 Thread Saagar Jha via Cocoa-dev
an ad-hoc fashion is to use the defaults command. > On Aug 6, 2023, at 01:53, Gabriel Zachmann via Cocoa-dev > wrote: > > I am pretty confused with the NSUserDefaults system. > > My app stores different settings for different monitors in the > [NSUserDefaults standardU

Confusion with app settings / NSUserDefaults

2023-08-06 Thread Gabriel Zachmann via Cocoa-dev
I am pretty confused with the NSUserDefaults system. My app stores different settings for different monitors in the [NSUserDefaults standardUserDefaults]. To do so, I generate defaults_ = [NSUserDefaults standardUserDefaults]; Then, I create a dictionary containing the default settings and

Re: Several different NSUserDefaults in the same app?

2021-04-06 Thread Martin Wierschin via Cocoa-dev
d this same approach in my own code. You can extend NSUserDefaults to add methods that provide a fallback value without first registering the values separately via a plist file. ~Martin Wierschin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Pl

Re: Several different NSUserDefaults in the same app?

2021-04-06 Thread Jack Brindle via Cocoa-dev
I agree with you, to an extent. NSUserDefaults is very good when used as a single-level repository for settings data. When you want to categorize the settings by using collections, it starts to show the same problems that a regular file has, except slightly worse. Collections are saved as an

Re: Several different NSUserDefaults in the same app?

2021-04-06 Thread Gabriel Zachmann via Cocoa-dev
> We don?t use NSUserDefaults in the app. Instead we have an > NSMutableDictionary that holds the settings, and we write them to a file when > they change. We read them in at app startup. > That allows us to actually have different settings for various items Yes, that certainly w

Re: Several different NSUserDefaults in the same app?

2021-04-04 Thread Jack Brindle via Cocoa-dev
We don’t use NSUserDefaults in the app. Instead we have an NSMutableDictionary that holds the settings, and we write them to a file when they change. We read them in at app startup. That allows us to actually have different settings for various items (these are USB devices like mice and

Re: Several different NSUserDefaults in the same app?

2021-04-04 Thread Alex Zavatone via Cocoa-dev
And if you want a nice simple HMAC256 encoding class to make the results securer if you want, I’ll happily toss one your way. > On Apr 4, 2021, at 2:22 PM, Gabriel Zachmann via Cocoa-dev > wrote: > > >> >> It appears you are trying to get NSUserDefaults to do someth

Re: Several different NSUserDefaults in the same app?

2021-04-04 Thread Gabriel Zachmann via Cocoa-dev
> > It appears you are trying to get NSUserDefaults to do something that Apple > doesn?t want it to do these days. Why not create your own defaults, > writing the data to a dictionary that is then written to a file that you save > in the ~/Library/Preferences folder, with a name

Re: Several different NSUserDefaults in the same app?

2021-04-04 Thread Steve Mills via Cocoa-dev
> On Apr 4, 2021, at 10:11, Richard Charles via Cocoa-dev > wrote: > > Why does Apple cache the defaults, what are the positive benefits? I have > only ever been infuriated with this process during development. For the same reason as any cache; speed and efficiency. Steve via iPad __

Re: Several different NSUserDefaults in the same app?

2021-04-04 Thread Richard Charles via Cocoa-dev
> On Apr 4, 2021, at 12:15 AM, Jack Brindle via Cocoa-dev > wrote: > > This does work in Big Sur, we use it ourselves. The down side is that you > don’t have the nice (and infuriating) caching of defaults that the system > provides. Why does Apple cache the defaults, what are the positive b

Re: Several different NSUserDefaults in the same app?

2021-04-04 Thread Richard Charles via Cocoa-dev
> On Apr 4, 2021, at 4:50 AM, Mike Abdullah wrote: > >> From the docs - init returns an initialized NSUserDefaults object whose >> argument and registration domains are already set up. This method does not >> put anything in the search list. Invoke it only if y

Re: Several different NSUserDefaults in the same app?

2021-04-04 Thread Mike Abdullah via Cocoa-dev
> On 3 Apr 2021, at 16:34, Richard Charles via Cocoa-dev > wrote: > >> >> On Apr 3, 2021, at 8:59 AM, Gabriel Zachmann wrote: >> >> Thanks a lot for your response! >> >>> How about something like this? >>> >>> NSUserD

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Jack Brindle via Cocoa-dev
Gabriel; It appears you are trying to get NSUserDefaults to do something that Apple doesn’t want it to do these days. Why not create your own defaults, writing the data to a dictionary that is then written to a file that you save in the ~/Library/Preferences folder, with a name of your choice

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Richard Charles via Cocoa-dev
> On Apr 3, 2021, at 9:56 AM, Gabriel Zachmann wrote: > > Sorry for asking: the shared instance is the one that is persistent, right? Looks like an instance created from alloc init would not be useful in your situation. It appears you would be in charge of persistence. NSUserDefault , Alloc

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Sandor Szatmari via Cocoa-dev
Gabriel > On Apr 3, 2021, at 10:55, Gabriel Zachmann wrote: > >  >> >>> >>> [ [NSUserDefaults userDefaultsWithName:@"monitor-name"] boolForKey:@"some >>> key"] >> >> I thought -addSuiteNamed: would allow you to ma

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Steve Mills via Cocoa-dev
> On Apr 3, 2021, at 12:00, Gabriel Zachmann via Cocoa-dev > wrote: > > Oh, and BTW: what happens if I do this: > >NSDictionary * monitor_user_defaults = [ [NSUserDefaults standardDefaults] > dictionaryForKey: displayName_]; >[monitor_user_defaults setObject:

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Gabriel Zachmann via Cocoa-dev
Oh, and BTW: what happens if I do this: NSDictionary * monitor_user_defaults = [ [NSUserDefaults standardDefaults] dictionaryForKey: displayName_]; [monitor_user_defaults setObject: anArray forKey: @"Pref1"]; Will that make NSUserDefaults automagically write the new preference

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Steve Mills via Cocoa-dev
> On Apr 3, 2021, at 11:02, Gabriel Zachmann via Cocoa-dev > wrote: > >  >> >> Why not use your top level NSUserDefaults as a dictionary and use each >> monitor name as a key for each object in the dictionary? Is that too clunky? > > I was thinking

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Gabriel Zachmann via Cocoa-dev
> Why not use your top level NSUserDefaults as a dictionary and use each > monitor name as a key for each object in the dictionary? Is that too clunky? I was thinking of that, but I was hoping for a more elegant solution. With the dictionary-per-monitor your suggesting, I guess I woul

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Gabriel Zachmann via Cocoa-dev
>> Can you explain to me, what is the difference between >> [[NSUserDefaults alloc] init] >> and >> [NSUserDefaults standardDefaults] >> ? >> I didn't get that from Apple's docs. >> > > > [...] > So it appears that using alloc

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Richard Charles via Cocoa-dev
> On Apr 3, 2021, at 8:59 AM, Gabriel Zachmann wrote: > > Thanks a lot for your response! > >> How about something like this? >> >> NSUserDefaults *monitor1 = [[NSUserDefaults alloc] init]; >>[monitor1 setBool:YES forKey:@"MyKey”]; >>

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Alex Zavatone via Cocoa-dev
Why not use your top level NSUserDefaults as a dictionary and use each monitor name as a key for each object in the dictionary? Is that too clunky? https://developer.apple.com/documentation/foundation/nsuserdefaults A default object must be a property list—that is, an instance of (or for

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Gabriel Zachmann via Cocoa-dev
Thanks a lot for your response! > How about something like this? > > NSUserDefaults *monitor1 = [[NSUserDefaults alloc] init]; > [monitor1 setBool:YES forKey:@"MyKey”]; > > BOOL value = [monitor1 boolForKey:@"MyKey"]; So, where is the kind of moni

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Gabriel Zachmann via Cocoa-dev
>> >> [ [NSUserDefaults userDefaultsWithName:@"monitor-name"] boolForKey:@"some >> key"] > > I thought -addSuiteNamed: would allow you to maintain/add a suite of defaults > for each monitor. Maybe. The doc says: """ The suiteN

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Richard Charles via Cocoa-dev
> On Apr 3, 2021, at 5:40 AM, Gabriel Zachmann via Cocoa-dev > wrote: > > But what I would like to have is a mechanism that lets me manage different > user defaults when the app is running on different monitors. > Something like > > [ [NSUserDefaults userDefault

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Sandor Szatmari via Cocoa-dev
at lets me manage different > user defaults when the app is running on different monitors. > Something like > > [ [NSUserDefaults userDefaultsWithName:@"monitor-name"] boolForKey:@"some > key"] I thought -addSuiteNamed: would allow you to maintain/add a suite of defa

Re: Several different NSUserDefaults in the same app?

2021-04-03 Thread Gabriel Zachmann via Cocoa-dev
rDefaults boolForKey:@"some key"] > etc should all work as expected. Yes, they do. But what I would like to have is a mechanism that lets me manage different user defaults when the app is running on different monitors. Something like [ [NSUserDefaults userDefaultsWithName:@"

Re: Several different NSUserDefaults in the same app?

2021-04-02 Thread Sandor Szatmari via Cocoa-dev
Would suites work for you? From the NSUserDefaults docs… Maintaining Suites - addSuiteNamed: Inserts the specified domain name into the receiver’s search list. - removeSuiteNamed: Removes the specified domain name from the receiver’s search list. Sandor Szatmari > On Apr 2, 2021, at 17

Several different NSUserDefaults in the same app?

2021-04-02 Thread Gabriel Zachmann via Cocoa-dev
I used to manage different NSUserDefaults in my app depending on which monitor it runs. So, I create filenames of the user defaults like this: NSString * defaults_name = [ NSString stringWithFormat:@"de.zach.MyApp.%@", displayname ]; Then I used to create the NSUserDefaults obje

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Quincey Morris
On Dec 7, 2016, at 16:39 , Charles Srstka wrote: > > when I pass nil to UserDefaults’ set(forKey:) method in Swift 3 […] it ends > up writing an NSNull instead of deleting the key […], since the method on > UserDefaults takes an Any? That sounds right. The case where it gives an opaquely wrapp

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Charles Srstka
> On Dec 7, 2016, at 1:00 PM, Quincey Morris > wrote: > > On Dec 7, 2016, at 08:24 , Charles Jenkins > wrote: >> >> If anyone knows how to play music from the library at a low volume, without >> screwing up the system volume for other apps, e.g. Music.app, I’d love to

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Jens Alfke
> On Dec 7, 2016, at 11:33 AM, Sean McBride wrote: > > I'm not sure I follow. I don't know hardly anything about audio playback, > but converting between bookmarks/paths/URLs is pretty trivial as they all are > basically different representations of the same concept. IIRC, in iOS you can get

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Sean McBride
On Wed, 7 Dec 2016 11:24:24 -0500, Charles Jenkins said: >Originally I did store bookmarks back when my app allowed users to pick >background music from their music libraries. But I could find no way to >play bookmarked library music at a low background volume, so I abandoned >that and just began

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Quincey Morris
On Dec 7, 2016, at 08:24 , Charles Jenkins wrote: > > If anyone knows how to play music from the library at a low volume, without > screwing up the system volume for other apps, e.g. Music.app, I’d love to > learn it. You can play audio using any volume you want (without any side effects on the

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Charles Jenkins
Sean, Originally I did store bookmarks back when my app allowed users to pick background music from their music libraries. But I could find no way to play bookmarked library music at a low background volume, so I abandoned that and just began using a .wav file stored with the app’s resources. If a

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Charles Jenkins
That makes sense. Thanks, Ken! On Wed, Dec 7, 2016 at 11:00 AM, Ken Thomases wrote: > On Dec 7, 2016, at 9:25 AM, Charles Jenkins wrote: > > > > I may be misusing NSUserDefaults. I want to store the name of a > background > > music file, which may be nil if the u

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Sean McBride
On Wed, 7 Dec 2016 10:25:46 -0500, Charles Jenkins said: >When the app starts up, we call NSUserDefaults.standard.register( [ “bgm” : > ) to default to the real file name, so the user will hear Charles, It's also best practice not to store file names/paths, but instead to store "bookmarks". Se

Re: Elementary NSUserDefaults Question

2016-12-07 Thread Ken Thomases
On Dec 7, 2016, at 9:25 AM, Charles Jenkins wrote: > > I may be misusing NSUserDefaults. I want to store the name of a background > music file, which may be nil if the user doesn’t want to hear anything. For > the time being, I have only two settings for

Elementary NSUserDefaults Question

2016-12-07 Thread Charles Jenkins
I may be misusing NSUserDefaults. I want to store the name of a background music file, which may be nil if the user doesn’t want to hear anything. For the time being, I have only two settings for my variable “currentBackgroundMusicFileName”: either a file that I distribute with the app, or nil

Re: observeValueForKeyPath called twice when changing NSUserDefaults value

2016-11-13 Thread Quincey Morris
On Nov 13, 2016, at 14:44 , Steve Mills wrote: > > NSUserDefaults can be observed using Key-Value Observing for any key stored > in it. OK, it’s documented in the header file. > Suggesting that the old/new values in the change dict shouldn't be used is > kinda silly. Why

Re: observeValueForKeyPath called twice when changing NSUserDefaults value

2016-11-13 Thread Steve Mills
On Nov 13, 2016, at 15:24:44, Quincey Morris wrote: > > Is this a new thread, or a continuation of the one we had a couple of weeks > ago (IIRC)? Brand new thread. I didn't see anything before. > NSUserDefaults is not documented as KVO compliant for any of its properti

Re: observeValueForKeyPath called twice when changing NSUserDefaults value

2016-11-13 Thread Quincey Morris
On Nov 13, 2016, at 13:00 , Steve Mills wrote: > > I've added an observer for an NSUserDefaults keyPath. Is this a new thread, or a continuation of the one we had a couple of weeks ago (IIRC)? NSUserDefaults is not documented as KVO compliant for any of its properties. You reall

observeValueForKeyPath called twice when changing NSUserDefaults value

2016-11-13 Thread Steve Mills
I've added an observer for an NSUserDefaults keyPath. This causes observeValueForKeyPath: to be called twice. Here's the call stack for the first call, starting from the setObject call (I'm actually calling setBool): #0 0x00017130 i

Re: NSUserDefaults Bindings Reset

2015-11-03 Thread Jerry Krinock
reset to default defaults might be to put your default defaults into a plist file in your app’s bundle, get its path with -[NSBundle pathForResource:ofType:], read in to a dictionary with -[NSDictionary dictionaryWithContentsOfFile:] and finally invoke -[NSUserDefaults registerDefaults:], pa

NSUserDefaults Bindings Reset

2015-11-01 Thread Michael de Haan 
I have made a test Project to understand resetting UserDefaults. A label’s value is bound to the shared UserDefaults in the UI, and works as expected when the Defaults are updated @IBAction fun changeMeaningOfLife……... let meaning = Int(arc4random() % 99) NSUserDefaults.standardUserDefault

Re: NSUserDefaults allocation size and CALayer memory usage

2015-06-29 Thread David Duncan
> On Jun 28, 2015, at 11:35 PM, Henrik Granaas-Helmers wrote: > > Hi there, > > I am new to Apple development, and new to this list. I have two questions > about memory on OS X. > > 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself &g

Re: NSUserDefaults allocation size and CALayer memory usage

2015-06-29 Thread Jens Alfke
> On Jun 28, 2015, at 11:35 PM, Henrik Granaas-Helmers wrote: > > 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself > using a megabyte—let alone 16 of those. It would be very interesting to know > why it allocates so much, and if there i

Re: NSUserDefaults allocation size and CALayer memory usage

2015-06-29 Thread Quincey Morris
On Jun 28, 2015, at 23:35 , Henrik Granaas-Helmers wrote: > > 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself > using a megabyte—let alone 16 of those. It would be very interesting to know > why it allocates so much, and if there is a

NSUserDefaults allocation size and CALayer memory usage

2015-06-28 Thread Henrik Granaas-Helmers
Hi there, I am new to Apple development, and new to this list. I have two questions about memory on OS X. 1. NSUserDefaults seems to allocate 16 MB memory at load. I can't see myself using a megabyte—let alone 16 of those. It would be very interesting to know why it allocates so much, a

Re: NSUserDefaults and home folder on different drive

2014-12-14 Thread Rick C.
Dec 11, 2014, at 3:10 PM, Rick C. wrote: >> >> So I found some old code where I was using NSAppleScript with "defaults >> write" ouch! :-) Sorry about that but curious why would this fail at times? >> Pretty sure that switching it to the proper NSUserDefaults wil

Re: NSUserDefaults and home folder on different drive

2014-12-11 Thread Rick C.
So I found some old code where I was using NSAppleScript with "defaults write" ouch! :-) Sorry about that but curious why would this fail at times? Pretty sure that switching it to the proper NSUserDefaults will work fine… > On Dec 11, 2014, at 10:24 PM, gweston wrote: >

Re: NSUserDefaults and home folder on different drive

2014-12-11 Thread Seth Willits
> On Dec 10, 2014, at 11:05 PM, Rick C. wrote: > > I write an NSString and NSData object to my app’s .plist and of course read > it back when needed and this works fine 99% of the time. On occasion a user > reports some trouble to me and I ask for the .plist and find out that this > NSString/

Re: NSUserDefaults and home folder on different drive

2014-12-11 Thread Jens Alfke
> On Dec 10, 2014, at 11:05 PM, Rick C. wrote: > > Hi, > > Digging deeper I find that most often the user has their home folder on a > different drive (external?) than the actual app. What would be the solution > to make sure these objects are written properly in this case? There's nothing

Re: NSUserDefaults and home folder on different drive

2014-12-11 Thread gweston
Rick C.  wrote: I write an NSString and NSData object to my app’s .plist and of course read it back when needed and this works fine 99% of the time. On occasion a user reports some trouble to me and I ask for the .plist and find out that this NSString/NSData object is missing. Digging deeper I

NSUserDefaults and home folder on different drive

2014-12-10 Thread Rick C.
Hi, I write an NSString and NSData object to my app’s .plist and of course read it back when needed and this works fine 99% of the time. On occasion a user reports some trouble to me and I ask for the .plist and find out that this NSString/NSData object is missing. Digging deeper I find that

Re: NSUserDefaults not sticking

2014-09-13 Thread Rick C.
/09/2014, à(s) 01:07, Rick C. escreveu: >> >> This is all very interesting and shows that there are issues out there, but >> back to my original issue if I’m writing and reading via NSUserDefaults and >> its not returning the expected values what else could be the trouble

Re: NSUserDefaults not sticking

2014-09-11 Thread Bavarious
Em 11/09/2014, à(s) 01:07, Rick C. escreveu: > > This is all very interesting and shows that there are issues out there, but > back to my original issue if I’m writing and reading via NSUserDefaults and > its not returning the expected values what else could be the trouble

Re: NSUserDefaults not sticking

2014-09-10 Thread Rick C.
This is all very interesting and shows that there are issues out there, but back to my original issue if I’m writing and reading via NSUserDefaults and its not returning the expected values what else could be the trouble? rc On Sep 11, 2014, at 11:59 AM, Charles Srstka wrote: > On Sep

Re: NSUserDefaults not sticking

2014-09-10 Thread Charles Srstka
ng. > > When you say "does not ... work", you really need to make clear what you mean. Fair point; sorry about that. Was in a hurry. The basic point is that NSUserDefaults and /usr/bin/defaults behave very differently when trying to access the preferences of a sandboxed application, sug

Re: NSUserDefaults not sticking

2014-09-10 Thread Charles Srstka
On Sep 10, 2014, at 10:34 PM, Marco S Hyman wrote: > On Sep 10, 2014, at 8:19 PM, Charles Srstka wrote: > >> >>> Where did you get the idea that NSUserDefaults doesn't work for sandboxed >>> apps? It certainly does. >> >> #impo

Re: NSUserDefaults not sticking

2014-09-10 Thread Graham Cox
On 11 Sep 2014, at 1:19 pm, Charles Srstka wrote: > NSDictionary *domain = [def persistentDomainForName:@"com.apple.TextEdit"]; The documentation states that this is not supported under sandboxing. When you say "does not ... work", you really need to make clear what you mean. --Graham ___

Re: NSUserDefaults not sticking

2014-09-10 Thread Marco S Hyman
On Sep 10, 2014, at 8:19 PM, Charles Srstka wrote: > >> Where did you get the idea that NSUserDefaults doesn't work for sandboxed >> apps? It certainly does. > > #import > > int main(int argc, const char * argv[]) { >@autoreleasepool { >

Re: NSUserDefaults not sticking

2014-09-10 Thread Charles Srstka
On Sep 10, 2014, at 9:39 PM, Graham Cox wrote: > On 11 Sep 2014, at 12:14 pm, Charles Srstka wrote: > >> If that's true, then why does the 'defaults' program work for sandboxed >> apps, while NSUserDefaults does not? > > > Where did you get the

Re: NSUserDefaults not sticking

2014-09-10 Thread Graham Cox
On 11 Sep 2014, at 12:14 pm, Charles Srstka wrote: > If that's true, then why does the 'defaults' program work for sandboxed apps, > while NSUserDefaults does not? Where did you get the idea that NSUserDefaults doesn't work for sandboxed apps? It

Re: NSUserDefaults not sticking

2014-09-10 Thread Kyle Sluder
y > there's something about the caching such that defaults, and I expect any > other process outside the one making the changes, DOES NOT return the latest > values you synched. It is absolutely the case that your app can use > NSUserDefaults to update defaults, can synch the

Re: NSUserDefaults not sticking

2014-09-10 Thread Charles Srstka
On Sep 10, 2014, at 7:41 PM, Kyle Sluder wrote: > On Wed, Sep 10, 2014, at 07:32 PM, Rick C. wrote: >> And about not relying on the .plist if we don’t rely upon it how do we >> write our prefs? I understand I should not manipulate it directly, but I >> am calling everythi

Re: NSUserDefaults not sticking

2014-09-10 Thread Scott Ribe
gh > the defaults system to reset them (as Kyle pointed out). Interesting point here... I was recently trying to debug some things I was doing with NSUserDefaults (stuffing printer settings into flattened XML apparently coded as Base64), and ran across the problem that the .plist is not updated w

Re: NSUserDefaults not sticking

2014-09-10 Thread Graham Cox
On 11 Sep 2014, at 10:32 am, Rick C. wrote: > And about not relying on the .plist if we don’t rely upon it how do we write > our prefs? I understand I should not manipulate it directly, but I am > calling everything via NSUserDefaults… Then you should be fine. The point is that t

Re: NSUserDefaults not sticking

2014-09-10 Thread Kyle Sluder
On Wed, Sep 10, 2014, at 07:32 PM, Rick C. wrote: > And about not relying on the .plist if we don’t rely upon it how do we > write our prefs? I understand I should not manipulate it directly, but I > am calling everything via NSUserDefaults… Continue using NSUserDefaults for all interac

Re: NSUserDefaults not sticking

2014-09-10 Thread Rick C.
directly, but I am calling everything via NSUserDefaults… rc On Sep 10, 2014, at 2:14 PM, Graham Cox wrote: > > On 10 Sep 2014, at 3:43 pm, Rick C. wrote: > >> Thanks for the help. So I have double-checked and the info in question that >> is not sticking is NSString

Re: NSUserDefaults not sticking

2014-09-10 Thread Kyle Sluder
On Wed, Sep 10, 2014, at 11:15 AM, Todd Heberlein wrote: > > in the past few years when it's happened it's been an early symptom of > > filesystem corruption. Sometimes there have been a bunch of leftover > > temporary lock(?) files in the Preferences directory. > > > > If you're getting reports

Re: NSUserDefaults not sticking

2014-09-10 Thread Todd Heberlein
> in the past few years when it's happened it's been an early symptom of > filesystem corruption. Sometimes there have been a bunch of leftover > temporary lock(?) files in the Preferences directory. > > If you're getting reports of this from users of your app, it might be worth > asking them t

Re: NSUserDefaults not sticking

2014-09-10 Thread Jens Alfke
I've run into issues of app preferences/defaults not persisting (across lots of apps, not necessarily just my own), and in the past few years when it's happened it's been an early symptom of filesystem corruption. Sometimes there have been a bunch of leftover temporary lock(?) files in the Prefe

Re: NSUserDefaults not sticking

2014-09-09 Thread Graham Cox
On 10 Sep 2014, at 3:43 pm, Rick C. wrote: > Thanks for the help. So I have double-checked and the info in question that > is not sticking is NSString/NSData being written: > > [[NSUserDefaults standardUserDefaults] setObject:stringObject > forKey:@“MyStringKey”]; >

Re: NSUserDefaults not sticking

2014-09-09 Thread Diederik Meijer | Ten Horses
info in question that > is not sticking is NSString/NSData being written: > > [[NSUserDefaults standardUserDefaults] setObject:stringObject > forKey:@“MyStringKey”]; > [[NSUserDefaults standardUserDefaults] setObject:dataObject > forKey:@“MyDataKey”]; > > Then being rea

Re: NSUserDefaults not sticking

2014-09-09 Thread Rick C.
Thanks for the help. So I have double-checked and the info in question that is not sticking is NSString/NSData being written: [[NSUserDefaults standardUserDefaults] setObject:stringObject forKey:@“MyStringKey”]; [[NSUserDefaults standardUserDefaults] setObject:dataObject forKey:@“MyDataKey

Re: NSUserDefaults not sticking

2014-09-08 Thread Graham Cox
On 9 Sep 2014, at 3:36 pm, Rick C. wrote: > I write some data to my .plist using standard NSUserDefaults Are you writing the .plist file, or are you using the NSUserDefaults object exclusively? From 10.9 the .plist isn't updated by NSUserDefaults, so values there can be very muc

NSUserDefaults not sticking

2014-09-08 Thread Rick C.
Hi, I write some data to my .plist using standard NSUserDefaults but recently I have been getting user feedback (less than 5% of users) that after every launch of the app the data needs to be entered again. I’m in the process of doing some debugging but can anyone think of a reason why this

Re: iTune Plist changes from NSUserdefaults

2014-01-13 Thread Jens Alfke
On Jan 12, 2014, at 2:44 AM, Madhavi Gundeti wrote: > And I took Sampling process in Activity monitor. Below is the output. The part of the sample output that you pasted in isn’t useful for looking at a hang. The useful part is the thread stacks at the start of the output. —Jens

Re: iTune Plist changes from NSUserdefaults

2014-01-12 Thread Madhavi Gundeti
Hi Jens, Now I developed UI application to perform the iTunes preferences changes. I installed my application on Mountain Lion.when I upgraded OS version from Mountain Lion to Mavericks 10.9.1 my application freezes. And I took Sampling process in Activity monitor. Below is the output. -

Re: iTune Plist changes from NSUserdefaults

2013-12-24 Thread Jens Alfke
On Dec 23, 2013, at 10:58 PM, Madhavi Gundeti wrote: > I am developing a daemon which runs as root That’s not recommended, because the daemon will have the ability to do all kinds of bad things. A bug could destroy someone’s system, or worse, a security hole in your code could let an attacke

Re: iTune Plist changes from NSUserdefaults

2013-12-23 Thread Madhavi Gundeti
I am developing a daemon which runs as root, so I wanted to change the user defaults from the daemon. Now I got it, It is not possible with NSUserdefaults. So I found another way to do that. I created another application which is called by this daemon and the application will do the job what

Re: iTune Plist changes from NSUserdefaults

2013-12-23 Thread Jens Alfke
On Dec 23, 2013, at 9:32 PM, Madhavi Gundeti wrote: > But Is there any way to change other user defaults as root user?? I don’t know. Look at CFPreferences; it has more options than NSUserDefaults. Is there a reason you have to do this as root, rather than the user whose prefs are be

Re: iTune Plist changes from NSUserdefaults

2013-12-23 Thread Madhavi Gundeti
at I am missing here. Why I am not able to change > these settings as root user. > > > Because every user has their own defaults. If you use NSUserDefaults in a > process whose userid is root, you’re changing the defaults of the ‘root' &g

Re: iTune Plist changes from NSUserdefaults

2013-12-22 Thread Jens Alfke
On Dec 11, 2013, at 4:45 AM, Madhavi Gundeti wrote: > Please let me know what I am missing here. Why I am not able to change > these settings as root user. Because every user has their own defaults. If you use NSUserDefaults in a process whose userid is root, you’re changing the defau

iTune Plist changes from NSUserdefaults

2013-12-22 Thread Madhavi Gundeti
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 a

Re: NSUserDefaults deeply nested subtle mountain lion difference

2013-07-27 Thread Keary Suska
On Jul 26, 2013, at 5:15 PM, Keith Knauber wrote: > From Apple Docs: > Values returned from NSUserDefaults are immutable, even if you set a mutable > object as the value. For example, if you set a mutable string as the value > for "MyStringDefault", the str

NSUserDefaults deeply nested subtle mountain lion difference

2013-07-26 Thread Keith Knauber
From Apple Docs: Values returned from NSUserDefaults are immutable, even if you set a mutable object as the value. For example, if you set a mutable string as the value for "MyStringDefault", the string you later retrieve usingstringForKey: will be immutable. The Apple docs have a

Re: Binding to NSUserDefaults

2013-03-18 Thread Seth Willits
> change a default. So I guess the answer is: "It always breaks on Uli's work > Mac" :-) > > Cheers, > -- Uli Kusterer > "The Witnesses of TeachText are everywhere..." > http://www.zathras.de > > On Mar 17, 2013, at 7:06 PM, Se

Re: Binding to NSUserDefaults

2013-03-18 Thread Uli Kusterer
TeachText are everywhere..." http://www.zathras.de On Mar 17, 2013, at 7:06 PM, Seth Willits wrote: > In nibs we bind to NSUserDefaults through NSUserDefaultsController, but is > there any point in using NSUserDefaultsController when binding to a default > through code? (Or using

Re: Binding to NSUserDefaults

2013-03-17 Thread Ken Thomases
On Mar 17, 2013, at 6:00 PM, Seth Willits wrote: > On Mar 17, 2013, at 11:31 AM, Ken Thomases wrote: > >>> In nibs we bind to NSUserDefaults through NSUserDefaultsController, but is >>> there any point in using NSUserDefaultsController when binding to a default >>

Re: Binding to NSUserDefaults

2013-03-17 Thread Seth Willits
On Mar 17, 2013, at 11:31 AM, Ken Thomases wrote: >> In nibs we bind to NSUserDefaults through NSUserDefaultsController, but is >> there any point in using NSUserDefaultsController when binding to a default >> through code? (Or using KVO, also.) It's always se

Re: Binding to NSUserDefaults

2013-03-17 Thread Ken Thomases
On Mar 17, 2013, at 1:06 PM, Seth Willits wrote: > In nibs we bind to NSUserDefaults through NSUserDefaultsController, but is > there any point in using NSUserDefaultsController when binding to a default > through code? (Or using KVO, also.) It's always seemed to w

Binding to NSUserDefaults

2013-03-17 Thread Seth Willits
In nibs we bind to NSUserDefaults through NSUserDefaultsController, but is there any point in using NSUserDefaultsController when binding to a default through code? (Or using KVO, also.) It's always seemed to work monitoring NSUserDefaults directly. -- Seth Wi

Re: NSUserDefaults locks up on 10.8

2012-08-09 Thread Martin Hewitson
>> I have a table view bound to shared user defaults with a key which returns >> an array of strings. >> I have a button for creating a new entry. This calls a piece of code like >> this: >> >> >> NSUserDefaults *defaults = [NSUserDefaults standardUs

Re: NSUserDefaults locks up on 10.8

2012-08-09 Thread Quincey Morris
On Aug 9, 2012, at 22:49 , Martin Hewitson wrote: > I have a table view bound to shared user defaults with a key which returns an > array of strings. > I have a button for creating a new entry. This calls a piece of code like > this: > > > NSUserDefaults *defau

  1   2   3   >