bugGNUstep - Bugs: bug #24807, NSUserDefaults doesn't support KVC

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #24807: NSUserDefaults doesn't support KVC

Submitted by:  Sergei Golovin <svg>
Submitted on:  Tue 11 Nov 2008 06:20:41 AM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Tue 11 Nov 2008 07:06:05 AM UTC, comment #1:

I implemented the trivial valueForKey: and setValue:forKey: methods ...though it's not entirely clear that NSUserDefaults should be KVC complient.

I couldn't find any documentation saying that the class is KVC complient in MacOS-X, and I did find a couple of comments on the web from people saying they thought it wasn't.
I also found this page ... http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/NSUserDefaultsController.html

At the end it says:
The NSUserDefaultsController method values returns a KVC-compliant object that is used to access these default values. To get the value of a default, use the valueForKey: method.

[[theDefaultsController values] valueForKey:@"userName"];

which seems to imply that NSUserDefaults is not KVC compliant (as it needs this special KVC-compliant object to access it).

However, your test program returns a value when I run it on MacOS-X, so it seems likely that Apple have added KVC as an undocumented feature, or are in the process of adding it.

Richard Frith-Macdonald <CaS>
Project Member
Tue 11 Nov 2008 06:20:41 AM UTC, original submission:

[NSUserDefaults valueForKey:@"theExistingKey"] falls in the segmentation fault:

------------------------------------------------------------------------------------------b
Uncaught exception NSUnknownKeyException, reason: Unable to find value for key
"theExistingKey" of object <NSUserDefaults: 0x80953d8>
------------------------------------------------------------------------------------------e

The test case is attached.

P.S.
gnustep-base r26997

Sergei Golovin <svg>

 

Attached Files
file #16822:  testNSUserDefaults.tar.gz added by svg (589B - application/x-gzip - the test case)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by svg (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 11 Nov 2008 07:06:05 AM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Tue 11 Nov 2008 06:20:41 AM UTCsvgAttached File-=>Added testNSUserDefaults.tar.gz, #16822

    Back to the top


    Powered by Savane 3.1-cleanup1