Re: write dictionary to file
Re: write dictionary to file
On Tue, Apr 08, 2003 at 10:35:31PM +0200, Gerriet M. Denkmann wrote:
>
When I run this small program:
>
>
id key = [ NSNumber numberWithInt: 42 ] ;
>
id value = @"the meaning of life" ;
>
id totalKnowledge = [ NSDictionary dictionaryWithObjectsAndKeys: value,
>
key, nil ] ;
>
if ( ![ totalKnowledge writeToFile: @"/tmp/abc.plist" atomically: YES ]
>
)
>
NSLog(@"confused");
>
>
I always get "confused".
>
I read the docs over and over again, but do not see anything wrong.
>
Is this a bug, or have I missed something?
You've missed something. From the docs:
writeToFile:atomically:
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag
Writes the contents of the receiver to the file specified by path. If
the receiver's contents are all property list objects (NSString,
NSData, NSArray, or NSDictionary objects), the file written by this
method can be used to initialize a new array with the class method
arrayWithContentsOfFile: or the instance method
initWithContentsOfFile:. This method recursively validates that all
the contained objects are property list objects before writing out the
file, and returns NO if all the objects are not property list objects,
since the resultant file would not be a valid property list.
A NSNumber is not a NSString, NSData, NSArray, or NSDictionary object.
--
=Nicholas Riley <email@hidden> | <
http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.