• 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
NSUserDefaults & thread safety
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUserDefaults & thread safety


  • Subject: NSUserDefaults & thread safety
  • From: Jonathan del Strother <email@hidden>
  • Date: Wed, 25 Jan 2006 11:47:43 +0000

According to the documentation, NSUserDefaults isn't thread safe. Does this mean that any access to NSUserDefaults outside of the main thread is a really bad idea, or am I safe to restrict write-access to the main thread and let any thread have read-access?


Jon

PS  -

On a related note...  if anyone can see why this code:

NSDictionary* oldFileDates = [[NSUserDefaults standardUserDefaults] objectForKey:@"File Dates"];
NSMutableDictionary* newFileDates = [oldFileDates mutableCopy];
[newFileDates setObject:[NSDate date] forKey:fileKey];
[[NSUserDefaults standardUserDefaults] setValue:newFileDates forKey:@"File Dates"];
[newFileDates release];



might occasionally cause this crash :

Thread 1 Crashed:
0 com.apple.CoreFoundation 0x90740ba4 CFRetain + 60
1 com.apple.CoreFoundation 0x90751fa4 CFDictionarySetValue + 448
2 com.apple.CoreFoundation 0x9078f32c writeXMLValue + 272
3 com.apple.CoreFoundation 0x9079cd98 _CFApplicationPreferencesSet + 212
4 com.apple.Foundation 0x928f2fa0 -[NSUserDefaults setObject:forKey:] + 108



- I'd love to hear about it. I'm hoping it's related to the aforementioned thread safety issues, because I can't see any other reason why it might occur.




Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSUserDefaults & thread safety
      • From: Derrick Bass <email@hidden>
  • Prev by Date: Re: Finding third party library
  • Next by Date: Re: NSUserDefaults & thread safety
  • Previous by thread: Re: Problems using Hotkeys and references to an NSSearchField
  • Next by thread: Re: NSUserDefaults & thread safety
  • Index(es):
    • Date
    • Thread