• 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
Re: write dictionary to file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: write dictionary to file


  • Subject: Re: write dictionary to file
  • From: Nicholas Riley <email@hidden>
  • Date: Tue, 8 Apr 2003 17:06:36 -0500
  • Mail-followup-to: "Gerriet M. Denkmann" <email@hidden>, email@hidden

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.

References: 
 >write dictionary to file (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: write dictionary to file
  • Next by Date: Re: write dictionary to file
  • Previous by thread: write dictionary to file
  • Next by thread: Re: write dictionary to file
  • Index(es):
    • Date
    • Thread