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

Group
 
 

bug #24807: NSUserDefaults doesn't support KVC

Submitter:  Sergei Golovin <svg>
Submitted:  Tue 11 Nov 2008 06:20:41 AM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

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
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by svg (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-11-11 CaS StatusNone Fixed
        Open/ClosedOpen Closed
    2008-11-11 svg Attached File- Added testNSUserDefaults.tar.gz, #16822

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code